Our React app started like a puppy ๐ถ. Cute, small, easy.
Five years later, it was a Great Dane chewing through our furniture ๐ช.
Every feature slowed us down.
Every release felt risky.
The โquick fixesโ piled up into tech debt.
We needed a way to break it apart without hitting โrewrite from scratch.โ
Micro-frontends became our path.
Hereโs how we split a monolith React app into micro-frontends, the pitfalls we hit, and the lessons weโd pass on.
๐ A Quick Story
When we pitched micro-frontends to leadership, the promise sounded perfect โจ: independent teams, faster deployments, cleaner boundaries.
Reality check:
Routing chaos,
Dependency drift,
UI looking like a patchwork quilt ๐จ.
And laptops screaming during local dev.
Still, breaking apart the monolith taught us valuable lessons worth sharing.
๐๏ธ Step 1: Define the Boundaries
You canโt just slice at random. We first mapped the appโs domains: auth, dashboard, checkout, settings. These became our candidate micro-frontends.
Tip: Slice by business capability , not by components. A โheader micro-frontendโ is a recipe for pain.
๐ฃ๏ธ Step 2: Routing the Split
The monolithโs react-router setup assumed one app. Micro-frontends demand a single โshellโ that delegates routes.
Example:
<BrowserRouter>
<Routes>
<Route path="/dashboard/*" element={<DashboardApp />} />
<Route path="/checkout/*" element={<CheckoutApp />} />
</Routes>
</BrowserRouter>
Pitfall : Overlapping routes caused chaos until we defined clear ownership of paths.
๐ Step 3: Handling Shared State
Our monolith had one Redux store. Duplicating that across apps = trap.
We isolated state per domain, then created a shared session store for auth.
Example:
import { createStore } from 'zustand';
export const useSession = createStore((set) => ({
user: null,
setUser: (user) => set({ user })
}));
Lesson: Share as little state as possible. Every extra slice ties teams back together.
โ๏ธ Step 4: Splitting the Build
We used Webpack Module Federation to load micro-frontends at runtime. Each team owned its build, but the shell wired them together.
Example:
new ModuleFederationPlugin({
name: 'checkout',
filename: 'remoteEntry.js',
exposes: {
'./CheckoutApp': './src/App',
},
});
Pitfall: Version drift โ ๏ธ. If one app shipped React 18 and another React 17 โ runtime errors.
๐จ Step 5: Tackling UI Consistency
Once split, each team styled differently. The UI looked like a collage ๐ผ๏ธ.
Fix: We built a shared design system package. Components were pulled live, not copied.
๐ป Step 6: Local Development Without Tears
At first, running the shell + every micro-frontend crushed laptops ๐ฅ๏ธ๐ฅ. Coffee cooled while builds spun.
Solution: Built mocks and stubs. Local dev usually meant one micro-frontend + stubbed neighbors.
๐บ๏ธ The Roadmap Weโd Recommend
Map domains first โ avoid atom-sized micro-frontends.
Centralize routing โ clear ownership of URL paths.
Keep shared state minimal โ only what must be global.
Align dependencies early โ React versions, styling, libraries.
Adopt a design system early โ stops UI drift.
Stub for local dev โ save your laptop (and sanity).
๐ Practical Takeaways
Micro-frontends are surgery ๐ฉบ, not a silver bullet.
Split by business capability , not UI pieces.
Align on dependencies + design systems early.
Test local dev workflows before scaling to teams.
๐ Something Extra (Resources)
๐ ๏ธ Webpack Module Federation Docs
๐ผ๏ธ ๐ธ The Hidden Costs of Micro-Frontends Nobody Talks About
๐ More Like This? Letโs Connect!
๐ฒ Follow me for more dev tips, tools, and trends!
- ๐ธ Instagram: @tahamjp
- ๐ง Dev.to: @tahamjp
- ๐ฆ X.com: @tahamjp
- ๐ฌ Telegram Channel: The Intelligent Interface
๐ Interface Insider (exclusive): Join the community โ share, learn, and collaborate with other members!
Check out my latest dev articles and tutorials โ updated weekly!
Letโs keep building cool stuff ๐
Top comments (3)
A very practical guide to taming a React monolith. Your emphasis on splitting by business capability, not components, is the crucial takeaway many teams miss.
Thanks! Yeah, that distinction made a huge difference for us โ organizing by capability keeps things way saner over time.
๐ Thanks for reading! Follow me for more front-end tips ๐ก