This guide shows tech leads and frontend architects how to move a storefront from Salesforce Commerce Cloud (SFCC) to a headless Next.js platform, one market at a time. The order matters: you measure first and switch markets later, and each step also shows what to monitor along the way. The examples use Next.js 16.4.6, @datadog/browser-rum 7.19.0, @unlighthouse/cli 0.20.0 and Fastly CLI 17.2.0, the current versions as checked on 1 December 2026.
Why observability comes first
A migration changes the code and the traffic at the same time. Without a baseline you cannot say whether the new storefront is faster or slower, and without per-market routing you cannot roll back a single market. Set up monitoring before the first market switches, so that every switch is a measured change.
The plan in this guide has eight steps:
- Measure the legacy baseline with CrUX.
- Choose the monitoring tool with an RFC.
- Run both storefronts side by side, with the same telemetry.
- Route traffic per market at the CDN.
- Compare legacy and new per page.
- Run go-live checks per market.
- Roll back per market.
- Onboard the legacy developers.
Step 1: measure the legacy baseline with CrUX
The Chrome UX Report (CrUX) holds field data from real Chrome users and reports each metric at the 75th percentile (p75) over a rolling window of 28 days. You can query an origin, which aggregates all pages, or a single URL, but CrUX only returns data for origins and pages with enough traffic.
Query the CrUX API for the legacy origin, using a Google Cloud API key for the Chrome UX Report API.
curl -s --request POST \
"https://chromeuxreport.googleapis.com/v1/records:queryRecord?key=$CRUX_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"origin": "https://www.example.com",
"formFactor": "PHONE",
"metrics": [
"experimental_time_to_first_byte",
"largest_contentful_paint",
"interaction_to_next_paint",
"cumulative_layout_shift"
]
}'
Then query the CrUX History API for the trend. It takes the same body on the records:queryHistoryRecord endpoint and returns weekly collection periods, 25 by default and up to 40.
Run the same query with a url instead of an origin for the key pages of each market: home, a category page and a product page. Write the results down in a short report with the p75 per metric, per form factor and per market, because every later comparison uses this report as its reference.
Step 2: choose the monitoring tool with an RFC
Monitoring is often split over several tools, and a migration is a good moment to choose one. Write a short RFC and let the teams review it.
Use these criteria:
- RUM and APM in one tool, with traces linked to browser sessions.
- Synthetic tests for the main journeys.
- Team ownership: each dashboard, monitor and alert belongs to one team.
- SLOs with burn-rate alerts.
- Configuration as code, for example with Terraform.
- A cost model that you can estimate per session and per span.
Also choose a lab tool for web vitals. A Lighthouse scanner such as Unlighthouse and a load test tool such as k6 answer different questions: Unlighthouse runs Lighthouse on many pages at once, while k6 tests how the platform behaves under load. Write down which question you need to answer first.
After the decision, let one product team go first, so that it finds the gaps before all teams start.
Step 3: run both storefronts side by side
Both storefronts serve real traffic for months, so give them the same telemetry, which lets you compare them on one dashboard.
The legacy storefront often has no RUM, but you can add the Datadog Browser SDK with the CDN async snippet or through a tag manager. Give it its own service name, for example storefront-legacy, and set sessionReplaySampleRate to 0 to keep the cost low. The new storefront gets RUM and APM in code, as the guide Datadog RUM and APM for the Next.js App Router shows.
Add the market to every RUM event on both storefronts:
datadogRum.setGlobalContextProperty('market', 'nl-nl')
With the CDN async snippet, make the same call on window.DD_RUM inside window.DD_RUM.onReady().
Then point the same synthetic tests at both storefronts, with the same journeys, test products and assertions.
Step 4: route traffic per market at the CDN
Salesforce documents a phased headless rollout for its own PWA Kit storefront, which uses eCDN routing rules and session bridging so that some pages run on PWA Kit and the rest on SFRA. With a custom Next.js front end on your own CDN, you build that routing yourself and also plan how sessions and baskets work across both storefronts.
On Fastly, an edge dictionary works well as a switch per market. Dictionaries are versionless, so a change takes effect at once without a new service version. Create a dictionary market_routing through the web interface, the API or the CLI, because a dictionary that you declare in custom VCL is not versionless. The key is the market prefix in the path, and the value is headless or legacy.
Read the dictionary in vcl_recv, before #FASTLY RECV:
set req.http.X-Storefront = "legacy";
if (req.url.path ~ "^/([a-z]{2}-[a-z]{2})(/|$)") {
set req.http.X-Storefront = table.lookup(market_routing, re.group.1, "legacy");
}
Add a request condition to each backend: the new backend gets req.http.X-Storefront == "headless" and the legacy backend gets req.http.X-Storefront != "headless". Fastly then assigns the backend and keeps shielding intact, while setting req.backend yourself after #FASTLY RECV would disable shielding.
Return the value in vcl_deliver, so tests and engineers can see which storefront served a page:
set resp.http.X-Storefront = req.http.X-Storefront;
Switch a market with one command:
fastly service dictionary-entry update --service-id="$FASTLY_SERVICE_ID" \
--dictionary-id="$DICTIONARY_ID" --key=nl-nl --value=headless
Fastly keeps no event log for dictionary changes, so record each switch yourself, for example as an event in Datadog, and your dashboards will show when a market moved. The edge cache can still hold pages from the old storefront, but if both storefronts send a Surrogate-Key header with the market, fastly service purge --key clears one market.
Step 5: compare legacy and new per page
Compare page types rather than site averages, because a fast home page can hide a slow product page.
For lab data, scan the same paths on both storefronts, which means each storefront needs a hostname that skips the market routing.
npm install -g @unlighthouse/cli
unlighthouse-ci --site https://legacy.example.com --urls /nl-nl/,/nl-nl/skincare/ \
--mobile --reporter jsonExpanded --output-path ./reports/legacy
unlighthouse-ci --site https://new.example.com --urls /nl-nl/,/nl-nl/skincare/ \
--mobile --reporter jsonExpanded --output-path ./reports/new
For field data, use RUM: filter on @type:view, split by service and the market attribute, and compare the p75 of @view.first_byte and @view.largest_contentful_paint per view name. Keep in mind that Datadog stores these values in nanoseconds.
Build one dashboard that puts the two storefronts next to each other, with a template variable for the market. Show time to first byte, the Core Web Vitals, the 5xx error rate and the synthetic test results. CrUX confirms the result later, because its 28-day window needs time to fill with new data.
Step 6: run go-live checks per market
Before the switch:
- The synthetic tests for the market pass on the new storefront.
- The dashboard and monitors filter on the market.
- The market’s sitemap comes from the storefront that serves the market.
- Old URLs redirect to the new URL structure.
- The rollback runbook names an owner.
- The baseline numbers for the market are at hand.
In the first hours after the switch:
- The
X-Storefrontheader showsheadlessin the synthetic test results. - RUM sessions for the market arrive under the new
service. - The 5xx error rate stays at or below the hour before the switch.
- Time to first byte is close to or better than the legacy baseline for the same pages.
- JavaScript errors do not rise.
Step 7: roll back per market
A rollback sets the dictionary value back to legacy, which affects one market while the other markets stay on the new storefront.
This only works if the legacy storefront can still serve the market, so keep its catalog, content and prices in sync until the market is stable. Agree on the rollback criteria before the go-live, for example a fast SLO burn rate or a failing checkout test, and practise the rollback once before the real switch. The guide SLOs and rollback runbooks for frontend teams covers the criteria and a runbook template.
Step 8: onboard the legacy developers
Legacy developers know the business rules, the markets and the edge cases, so bring them onto the new platform early. Map the concepts they know, such as cartridges, controllers and templates, to the new code base. Let them join the go-live checks and use the comparison dashboard, and add them to a team in Datadog so that alerts reach them.
In practice
An international cosmetics retailer moved from Salesforce Commerce Cloud to a headless Next.js platform, market by market. We partnered with the client’s architecture team and supported its 7 product teams, 5 on web and 2 on the app. The product teams and an external delivery partner built the new platform.
The legacy site had a time to first byte of about 2,800 ms in CrUX data from May 2025, while the target was 800 ms. Monitoring was split over two tools, and the legacy site had no RUM. The work started in May and June 2025 with a performance report based on CrUX data and a monitoring strategy. In November 2025, an RFC chose Datadog over the incumbent tool, and Unlighthouse was chosen over k6 for web vitals. One product team started with tracing in production, and from January to June 2026 all 7 teams got team ownership in Datadog, with standard dashboards, monitors and synthetic tests. Fastly routed each market to one of the two storefronts.
The first markets went live in January 2026, about 10 countries were live by May 2026, and the other markets followed in phases in July 2026. We monitored the market go-lives in Datadog, using a dashboard that compared the new storefront with the legacy storefront. The teams wrote SLO and rollback runbooks for each market, and 4 legacy developers were onboarded to the new platform. Read the full case study.
Checklist
- Measure a CrUX baseline per market and per page type.
- Choose one monitoring tool with an RFC.
- Add RUM to the legacy storefront with its own
servicename. - Add the market to every RUM event.
- Run the same synthetic tests on both storefronts.
- Route each market with one dictionary entry.
- Log every switch as an event.
- Compare page types on one dashboard.
- Agree on rollback criteria before each go-live.
- Onboard the legacy developers before the last market moves.
For a review of your migration monitoring, see the frontend observability assessment or get in touch.
Sources
- Chrome for Developers: CrUX API
- Chrome for Developers: CrUX History API
- web.dev: Web Vitals
- Salesforce: Phased headless rollouts
- Fastly: About dictionaries
- Fastly: table.lookup
- Fastly: Regular expressions in VCL
- Fastly: About conditions
- Fastly: Shielding
- Fastly: req.backend
- Fastly CLI: dictionary-entry update
- Fastly CLI: purge
- Fastly: Surrogate-Key
- Unlighthouse: CI integration
- Datadog: Browser monitoring client-side setup
- Datadog: Browser advanced configuration
- Datadog: RUM browser data collected
- Datadog: Unified Service Tagging
- Datadog: HTTP testing
- Datadog: Teams