A React 18 migration playbook
April 15, 2026 · 10 min read
Seven days is short for a 28-module migration. Here is how we did it without breaking the platform.
The setup
A 28-module React 17 codebase, 4.1MB initial bundle, Time to Interactive of 7.2 seconds in Lighthouse. Sales calls were ending before the demo loaded. The platform team had three months on the roadmap to "fix performance." Sales had three months of new prospects, of which two months would be gone before the platform team finished planning. We bet the work could land in seven calendar days.
This is the day-by-day playbook of what we did, what we cut, and what we shipped.
What we did not change
Before anything else, we listed what we would not touch. Material UI stayed. Redux Toolkit stayed. The auth flow stayed. The 28 features stayed feature-complete and behaviorally identical. The diff had to be small enough that a senior reviewer could read it and convince themselves nothing broke.
Anything outside that list got cut, even good ideas. The hardest part of the seven days was telling teammates "we are not refactoring that today" eight or nine times.
Day 1: profiling and the bet
Built a clean Lighthouse run as the baseline. TTI 7.2s, FCP 2.1s, initial bundle 4.1MB. The bundle analyzer told the story: every module was loaded eagerly, every icon library was bundled, the date-fns import pulled in the whole library, Material UI imports went through the top-level barrel.
The bet:
- Switch to React Router v6 with route-level React.lazy and Suspense.
- Replace the top-level barrel imports with named imports.
- Introduce a single navigationConfig that drives the sidebar and the router from one list.
- Skip memoization, skip context refactors, skip every "while we're here" idea.
If those four changes did not move the number, we would stop and replan.
Day 2: navigationConfig and feature modules
Wrote a navigationConfig with one entry per module, each one a lazy import. The sidebar started reading from the config. The router started reading from the config. The two stopped drifting.
We also locked feature module surfaces: each module exposes one default export and an optional secondary entry. Nothing else is importable from outside the module. Locked imports made the code-split boundaries match the module boundaries, which gave us clean chunks instead of webpack inventing them.
Day 3: React Router v6 and route-level Suspense
Swapped React Router v5 for v6. The new createBrowserRouter API turned out to be the cleanest path. Each route uses React.lazy on the module entry. Suspense at the route level shows a skeleton loader until the chunk arrives.
First Lighthouse re-run: TTI 4.1s, initial bundle 1.8MB. The biggest single win came from the lazy boundary, not from any micro-optimization.
Day 4: imports and icons
Hunted down barrel imports. The Material UI barrel was the worst offender: a single import of @mui/material/* pulled 1.5MB of components we did not use. Replaced every import with named subpaths (@mui/material/Button instead of @mui/material). That alone took 400KB off the bundle.
Replaced the icon library with a tree-shakable per-icon import. That was another 220KB.
Replaced date-fns with three named functions actually used in the app. Another 80KB.
Day 5: profiling the second-paint
TTI was down to 2.4s, but the post-FCP frames were still janky. Used the React Profiler to find the worst offenders. A single component with a 600-row table was rendering on every input keystroke because of a parent re-render. One memo fix dropped it to a stable 60fps. That was the only memoization we did the whole week.
This was a deliberate choice. Aggressive memo would have locked invariants we wanted free to change later. Profile-first kept us honest.
Day 6: regression sweep
Spent a full day clicking through every module on three browsers. Found four bugs: a broken modal close button, a stale icon in one section, a missing keyboard shortcut, and a CSS regression on a dropdown that was using a deprecated import path.
Fixed all four. None were caused by the migration; they were preexisting bugs that the regression sweep made visible. We kept them in the same PR. Future-us will thank current-us for catching them.
Day 7: Lighthouse, audit, and ship
Final Lighthouse run: TTI 2.0s, FCP 1.1s, initial bundle 1.55MB. Sent the audit report to the sales team. Tagged the release. Shipped.
What it actually shipped
- Time to Interactive: 7.2s to 2.0s, verified in Lighthouse.
- Initial bundle: 4.1MB to 1.55MB.
- Zero regressions in the first month after release.
- Sidebar reorganized from 3 sections to 6 hubs in the same release because the new config made it trivial.
- Per-route lazy chunks meant each module loaded in under 400ms on a cold cache.
What I would do differently
I would add a Lighthouse budget to CI from day one. We caught regressions by hand for a month before the budget landed. A budget would have caught a 200KB regression that snuck in two weeks after launch.
I would enforce the locked-import rule with ESLint, not the README. The README rule survived two months before someone bypassed it and pulled a feature module into another feature module.
The thing I keep coming back to
The migration worked because of what we did not do, not because of what we did. Boring decisions (React Router v6, React.lazy, named imports) beat exotic ones (custom code-splitting, hand-rolled router, build-time tree-shaking plugins) every time. The exotic version of this migration takes three months. The boring version took seven days.
If you are looking at a platform you suspect is slow because of structure rather than features, profile first, write the list of changes you will not make, and then change as little as possible. The wins are out there. You do not have to rewrite anything to find them.
Next post
D3 at 10K nodes
Canvas over SVG, force in a Web Worker, hit detection without a quadtree, and what 100K would need.