Skip to main content

Migrating an AngularJS Website to AEM with a React SPA Editor Front End: Lessons Learned

Lessons from migrating an AngularJS and Node.js site to Adobe Experience Manager with a React SPA Editor front end: components, JSON models, payments and SEO.

Amit Verma9 min read
Migrating an AngularJS Website to AEM with a React SPA Editor Front End: Lessons Learned

A framework migration is never just a rewrite. Moving from AngularJS to AEM changes who owns the page: developers stop shipping content, and authors start building it. Plan for that shift and the code follows. Ignore it and you rebuild the old site in a new framework, with all the old problems.

One of the projects on my portfolio is the migration of AXA Philippines from a legacy AngularJS (Angular 1) and Node.js stack to Adobe Experience Manager (AEM), with a React front end built on AEM's SPA Editor. My focus was the React front end, including the online payment forms and their integrations with the 2C2P, PesoPay and Paynamics payment gateways.

This post isn't a step-by-step tutorial. It's the set of lessons I'd hand any team starting a similar migration: how the SPA Editor actually works, where to spend time before writing code, how to treat forms and payments, how to protect your URLs, and, because it's 2026, what I'd choose instead if I were starting the same project today.

Why teams leave AngularJS for AEM

AngularJS reached end of long-term support at the end of 2021, so every AngularJS site is now running on a framework that no longer receives security fixes. But the framework is rarely the only problem. On most AngularJS marketing sites, every content change, from a new banner to a corrected premium table, needs a developer, a build and a deployment.

AEM addresses the second problem directly. Authors build and edit pages from approved components, with workflows and approvals, while developers focus on the components themselves. Choosing a React front end with the SPA Editor kept a modern component model for the developers while giving authors in-context editing.

How the AEM SPA Editor works, in one paragraph

With the SPA Editor, AEM stores the page as content and exposes it as JSON through a .model.json endpoint. The React app loads that model, then walks through it and renders a React component for each item, matched by the item's AEM resource type. Each React component registers itself for a resource type with MapTo, and can supply an EditConfig that tells the editor how to show the component when it's empty. In the authoring environment, AEM overlays its editing tools on top of your running React app.

A component's JSON in the model looks like this:

1{
2  ":type": "mysite/components/promo",
3  "title": "Protect what matters",
4  "text": "Compare plans in minutes.",
5  "ctaLabel": "Get a quote",
6  "ctaLink": "/content/mysite/en/quote"
7}

And the matching React component:

1import { MapTo } from '@adobe/aem-react-editable-components';
2
3const PromoEditConfig = {
4  emptyLabel: 'Promo',
5  isEmpty: (props) => !props || !props.title,
6};
7
8function Promo({ title, text, ctaLabel, ctaLink }) {
9  return (
10    <section className="promo">
11      <h2>{title}</h2>
12      {text && <p>{text}</p>}
13      {ctaLink && <a href={ctaLink}>{ctaLabel}</a>}
14    </section>
15  );
16}
17
18export default MapTo('mysite/components/promo')(Promo, PromoEditConfig);

Once you see that :type is the bridge between AEM and React, most of the SPA Editor's behaviour stops being mysterious.

Lesson 1: Inventory every component before writing one

The most valuable week of a migration is the one before any code is written. Go through the existing site page by page and list every distinct piece of UI: heroes, promo tiles, plan comparison tables, FAQs, calculators, forms. For each one, decide:

  • Is it authorable? Content that authors should change becomes an AEM component with a dialog. Behaviour that should never change stays in code.
  • What are its fields? The dialog fields become the JSON properties your React component receives. Name them once, and use the same names in AEM and React.
  • Is it a duplicate? AngularJS sites accumulate near-identical directives over the years. Three "almost the same" promo blocks should become one component with a variant field.

The output is a component catalogue that designers, AEM developers, front-end developers and authors all agree on. Every later disagreement is cheaper to settle against that document than in code review.

Lesson 2: Treat the JSON model as an API contract

In an SPA Editor project, the JSON model is the interface between two teams: the AEM back end that exports it and the React front end that renders it. Treat it like any other API:

  • Agree on the shape first, per component, before either side builds it.
  • Mock it. Front-end developers shouldn't wait for AEM components to exist. A saved model.json per page lets the React side build and test independently.
  • Never rename silently. Renaming a property on one side breaks rendering without an error. The component just shows empty.

This is the same discipline as a public API between services, and it pays off the same way.

Lesson 3: Design for the empty state, because authors see it first

Developers test components with complete content. Authors meet them empty: they drag a new component onto the page and see whatever it renders with no data. Without an EditConfig, that's often nothing at all, so authors can't find or select the component they just added.

Every component needs a deliberate empty state: an emptyLabel so the editor shows a placeholder, and an isEmpty check that matches what "empty" really means for that component. Test every component the way an author first sees it, not the way a developer last left it.

Lesson 4: Don't port AngularJS patterns, translate them

The fastest way to build a fragile React app is to translate AngularJS line by line. Patterns that were idiomatic in AngularJS map to different ideas in React:

  • Two-way binding → controlled components. Form state lives in React state and flows down; changes flow up through handlers.
  • Services and factories → hooks and modules. Shared logic like pricing rules or API calls becomes plain modules, exposed to components through custom hooks.
  • $scope events → props and context. Cross-component communication becomes explicit data flow instead of broadcast events.
  • Directives → components. Most directives become components, but some were really CSS or AEM concerns in disguise.

The goal isn't feature parity with the old code. It's the same user-facing behaviour built the way React expects.

Lesson 5: Forms and payments deserve their own architecture

Online payment forms were the most business-critical part of my work, and the place where the line between front end and back end matters most. All three gateways we integrated (2C2P, PesoPay and Paynamics) follow the same broad pattern for hosted payments: the merchant sends the customer to the gateway with a payment request that's signed using a secret key, the customer pays on the gateway's side, and the gateway reports the result back to the merchant.

That leads to a few rules I'd apply to any payment integration:

  • Never sign in the browser. The secret key must never reach the client. The front end asks the server to create the payment request, and the server signs it.
  • The browser only carries the request. The React app receives the gateway URL and the signed fields from your server, and submits them.
  • Trust the server-to-server result, not the redirect. When the customer returns to your site, show a "confirming your payment" state, and treat the payment as complete only once your server has verified the gateway's notification.
  • Validate twice. Client-side validation is for user experience; server-side validation is for correctness. Always both.

The front-end side of that flow is small, and that's the point:

1async function startPayment(policyId) {
2  // The server validates the order and returns the gateway URL plus signed fields.
3  const res = await fetch('/api/payments/session', {
4    method: 'POST',
5    headers: { 'Content-Type': 'application/json' },
6    body: JSON.stringify({ policyId }),
7  });
8  if (!res.ok) throw new Error('Could not start payment');
9  const { actionUrl, fields } = await res.json();
10
11  // Hosted payment pages are reached with a form POST.
12  const form = document.createElement('form');
13  form.method = 'POST';
14  form.action = actionUrl;
15  Object.entries(fields).forEach(([name, value]) => {
16    const input = document.createElement('input');
17    input.type = 'hidden';
18    input.name = name;
19    input.value = value;
20    form.append(input);
21  });
22  document.body.append(form);
23  form.submit();
24}

Swapping or adding a gateway then becomes mostly a server-side change, while the React components stay the same. I'll cover the three gateways in detail in a follow-up post.

Lesson 6: Protect your URLs and your search rankings

A migration can quietly destroy years of search rankings if URLs change without redirects. Build a complete map of old URLs to new ones before launch, and add permanent (301) redirects for every page that moves.

AngularJS adds a twist: many AngularJS sites use hash-based URLs such as /#!/products/health. The part after # is never sent to the server, so server-side redirects can't see it. If your old site used hash URLs, you need a small client-side script on the new site that reads window.location.hash and sends the visitor to the right page. And make sure your new site's pages have clean, crawlable URLs from day one.

Lesson 7: Watch the bundle as the component library grows

An SPA Editor site loads one React application for the whole site, and it grows with every component you add. Left alone, a page with three simple components ends up downloading the code for fifty.

  • Lazy-load heavy components such as calculators and payment forms with dynamic import(), so pages without them never download that code.
  • Keep shared dependencies small. A date library or UI kit added for one component ships to every page.
  • Measure per page, not per build. Check what the homepage actually downloads, because that's what most visitors experience.

Lesson 8: Content migration and authors are part of the project

Code is only half of the launch. Existing content has to move into AEM, through scripts for large volumes and by hand where pages are being redesigned anyway. And authors need to be ready on launch day, not after it.

My strongest recommendation here is to involve authors early: show them components while they're still being built, and let their feedback shape field names and dialogs. A component that's hard to author will be authored badly, no matter how good its code is.

If I were starting this project today

The lessons above still apply, but the technology choice would change. Adobe has deprecated the SPA Editor for new projects: it's still supported for existing sites like the one we built, but its SDKs no longer receive enhancements, and Adobe recommends the Universal Editor for new work.

For a content-heavy marketing site like this one, I'd seriously consider AEM Edge Delivery Services, authored with the Universal Editor or documents. It delivers excellent performance by default and keeps front-end code deliberately small. Payment forms and calculators would become isolated, lazily loaded pieces of interactivity rather than part of one site-wide application. I've written a separate guide on AEM Edge Delivery Services for React developers that covers what changes.

The component catalogue, the JSON contract, the empty states, the payment architecture and the redirect map would all carry over unchanged. Those were never really about the SPA Editor.

Migration checklist

  1. Component catalogue agreed by design, AEM, front-end and authoring teams.
  2. JSON contract defined per component, with mock models for front-end development.
  3. Empty states and edit configs for every component, tested as authors see them.
  4. AngularJS patterns translated, not ported line by line.
  5. Payments signed and verified server-side, with the browser only carrying the request.
  6. Complete URL redirect map, including any hash-based AngularJS routes.
  7. Heavy components lazy-loaded, with per-page bundle sizes measured.
  8. Content migration and author training planned as part of the project.

FAQ

Is the AEM SPA Editor deprecated?

Yes, for new projects. Adobe deprecated the SPA Editor with AEM 6.5.23, and its SDKs no longer receive enhancements. Existing SPA Editor sites continue to be supported. For new projects, Adobe recommends the Universal Editor.

Can I reuse my AngularJS code when migrating to React?

Mostly not directly. Business rules and API logic can often be lifted into plain JavaScript modules, but templates, directives and two-way binding have to be rebuilt the React way. The bigger reuse is knowledge: the old site is the best specification you have for behaviour and edge cases.

How do I keep SEO rankings during a migration?

Map every old URL to its new one and add permanent redirects before launch. If the old site used hash-based URLs, handle them with a client-side redirect, because servers never see the part after the #. Keep titles, descriptions and content quality at least as good as before.

Should payment forms be built in AEM or in the front end?

The user interface lives in the front end, but signing payment requests and verifying results must happen on the server. The browser should never hold the gateway secret, and a payment should only count as complete once the server has verified the gateway's notification.

Share this article

Found it helpful? Share it with your network.

Keep reading