Micro-Frontend Composition: Build, Server or Client
On this page
The decision you're making
Every micro-frontend architecture answers one question: where do the pieces come together? The answer decides whether teams can really deploy alone, how fast pages load, and how hard the system is to run.
The options side by side
| Composition | How it works | Independent deploys? | Main cost |
|---|---|---|---|
| Build time | Each micro-frontend is an npm package; the shell installs and bundles them | No: the shell must rebuild | Release coupling |
| Server side | The server stitches HTML fragments from each team into one page | Yes | Server infrastructure and caching |
| Edge side | A CDN assembles fragments, for example with ESI includes | Yes | Edge tooling, harder debugging |
| Client side, runtime | The browser loads each team's JavaScript and mounts it | Yes | More requests, shared dependencies |
| Iframes | Each piece is its own page inside a frame | Yes | Poor integration and accessibility |
Build-time composition is a trap for independence
Publishing each micro-frontend as an npm package looks clean. The shell's package.json lists @shop/cart@4.2.0, and the bundler builds one app. But every cart release now needs a shell release too, so teams are back on one release train. It's a fine way to share a design system. It isn't micro-frontends.
Server-side and edge composition
The server, or a CDN at the edge, asks each team's service for an HTML fragment and combines them into one response. The user gets a complete page in one request, which is good for first load and for search engines. The costs are infrastructure: a composition layer, fragment caching, and timeouts so one slow team doesn't delay every page. Frameworks with server rendering and streaming make this easier than it used to be.
Client-side composition
The shell loads in the browser, then fetches and mounts each team's JavaScript at run time. This is the most common choice for single-page apps, and the next four lessons build it step by step:
- A mount contract, the small interface every micro-frontend exposes so the shell can start and stop it (Day 4).
- Native ES modules with import maps, which load each team's code by name and share one copy of React using only browser features (Day 5).
- A shell with routing, which decides which micro-frontend owns each URL (Day 6).
- Web components and iframes as isolation boundaries (Day 7).
You'll also meet two popular tools built on the same ideas. Module Federation, a feature of webpack, Rspack, Vite and other bundlers, loads separately built code and shares libraries at run time. single-spa is an orchestrator that manages mounting and unmounting. Both are good choices once you understand what they automate, which is what this course teaches.
How to choose
- Content-heavy, public pages that need fast first load and good SEO: server-side or edge composition.
- Logged-in single-page apps with rich interaction: client-side composition.
- A legacy app you're migrating piece by piece: iframes or client-side mounting, so old and new can live side by side.
- Only sharing UI components: a regular npm package, and no micro-frontends at all.
Mixing is normal. Many shops render public product pages on the server and compose the logged-in account area in the browser.
Check yourself
The shell installs specific package versions at build time and bundles them, so a new cart release only reaches users after the shell rebuilds and redeploys. Teams end up waiting for the shell team, which is the coupling micro-frontends are meant to remove. Build-time composition gives code separation, not independent deployment.
Server-side or edge composition. The server or CDN assembles each team's fragment into one complete HTML page, so readers and search engines get the full content in a single response, with no waiting for client-side JavaScript. Each team can still deploy its fragment independently.
Extra network requests, because the shell loads first and then fetches each micro-frontend's code, plus the risk of loading shared libraries such as React more than once if the teams don't coordinate. Both can be managed with preloading and a shared import map, but they cost first-load performance if ignored.
Client-side composition. The app already runs mostly in the browser, search engines don't need its pages, and client-side loading gives each team independent deploys with simple infrastructure. Server-side composition would add complexity for a benefit, the first-load HTML, that matters less here.
They automate the same ideas: loading separately built code at run time, sharing libraries like React, and starting and stopping each team's code. Understanding the mount contract and import maps first makes it much easier to judge what those tools do for you and when you need them.