Nguyen Le Phong

Foundations of Software ArchitecturePart 6 of 15

When Micro-Frontends Are Worth It (and What You Pay)

Micro-frontends let each team ship its own slice of the UI.

Five teams share one frontend repo. Checkout wants to ship a fix on Tuesday, but the release train leaves on Thursday, and the dashboard team's half-finished feature is riding it too. Then someone tweaks a shared date helper and the onboarding flow breaks on a screen nobody in checkout has ever opened. Everyone is waiting on everyone, and the code itself isn't even the problem.

Engineers from several frontend teams crowd around one table with laptops, sticky notes and a deploy dashboard, all waiting for the same release window.
When every team ships through one release window, a one-line fix waits for everybody else's work.

That's usually the moment someone says "micro-frontends." The pitch is easy to like: the backend split its monolith into services, so why not the UI? Each team builds and deploys its own slice, and the page gets put back together in the browser or on the server.

The pitch is half right. Micro-frontends really can stop teams from blocking each other. They also make your frontend a distributed system, with all the version, network and debugging chores that come with one. I've built this shape before (an Angular host with React modules, each deploying on its own), and this is the post I'd want to read first: what micro-frontends are, how the pieces get stitched together, what they cost, and when a well-organized monorepo does the job for a lot less.

What a micro-frontend actually is

The term first appeared on the Thoughtworks Technology Radar in November 2016. Cam Jackson's long write-up on martinfowler.com gives the definition most people quote: "an architectural style where independently deliverable frontend applications are composed into a greater whole."

In practice that means three things. One team owns a slice end to end, usually a business area like checkout or search rather than a technical layer. That team builds, tests and deploys its slice without waiting for anyone. And a container app (you'll also hear shell or host) loads the slices and handles the shared bits: routing, login, the top nav.

The big change is who has to talk to whom before a release. In one shared codebase, any edit to shared code can break any team, so every deploy needs a round of checking. With micro-frontends, the checkout team ships checkout. What the teams still agree on is the contract between the shell and each slice: which URL it mounts on, which props or events it accepts, which shared libraries it expects to find on the page.

A shell app at the top loads three micro-frontends that Team A, Team B and Team C deploy on their own, and the browser shows them as one page. Shell / Container App routing · auth · nav · shared libraries TEAM A Checkout MFE React · own pipeline TEAM B Dashboard MFE React · own pipeline TEAM C Profile MFE Angular · being replaced v2.4.1 · live v1.9.0 · live v3.1.2 · live BROWSER: one page, three separate deploys
The shell owns routing, login and the top nav. Each team ships its slice through its own pipeline and version, and the user still sees one page. The Angular slice is being phased out, the kind of framework mix that makes sense during a planned migration.

Five ways to stitch the pieces together

Micro-frontends are a family of techniques. How you put the pieces back together decides how independent your teams really are, and how long users wait for the page.

ApproachHow it worksTrade-off
Build-time integration (npm packages) Each slice is published as a versioned package. The shell installs them all and bundles everything into one build. Easy to start. Every change still needs a new shell build and release, so teams end up shipping in lockstep. Cam Jackson's article recommends strongly against it for exactly that reason.
Server-side composition A server or edge layer fetches HTML fragments from each team and assembles the page before it reaches the browser. Zalando's Tailor is a well-known example (archived since 2022). Fast first paint and good for SEO. You now run and monitor a composition layer, and one slow fragment can hold up the whole page.
Run-time via Module Federation Separate builds expose modules that the shell loads at runtime from their own URLs. Shared libraries like React are negotiated so the page can load them once. Teams deploy without touching the shell. In exchange you manage shared versions, remote entry files and debugging across several builds.
iframes Each slice runs in its own iframe and talks to the shell through postMessage. The strongest isolation you'll get. Routing, deep links, focus, scroll and accessibility all need custom plumbing, and the result rarely feels like one app.
Web Components Each slice registers a custom element such as <checkout-app>, and the shell drops it into the page. Framework-neutral and built into the browser. Shared state is still yours to solve, and server rendering takes extra work.

Module Federation arrived with webpack 5 in 2020, and the Module Federation project now supports Rspack as well. It's the runtime option most of this post talks about. Here's a minimal shell config:

// webpack.config.js (shell)
const { ModuleFederationPlugin } = require("webpack").container;

module.exports = {
  plugins: [
    new ModuleFederationPlugin({
      name: "shell",
      remotes: {
        checkout: "checkout@https://cdn.example.com/checkout/remoteEntry.js",
      },
      shared: {
        react: { singleton: true, requiredVersion: "^18.3.0" },
        "react-dom": { singleton: true, requiredVersion: "^18.3.0" },
      },
    }),
  ],
};

The shared block is where a lot of the real work lives. singleton: true allows only one copy of React on the page, and the plugin docs name React and react-dom as libraries with global internal state that need exactly that. requiredVersion says which range this build can live with. Get these wrong and users either download React twice or hit a runtime error when versions don't line up.

If SEO matters, look at the server first

For pages that have to rank in search, server-side composition sends finished HTML to the browser. Runtime federation pays off later, once you have the pipelines and monitoring to run many builds side by side.

Why teams split the frontend

The reasons tend to trace back to four pressures:

  • Independent deploys: the one people mention first. When many teams share one build, every release waits for the slowest feature to clear QA. With separate slices, checkout ships on Tuesday and nobody else has to be ready. Each release also touches less code, so a bad one breaks less.
  • Ownership: a team that builds, tests, deploys and watches its own slice in production has a clear stake in it. On-call, dashboards and error budgets all have an obvious owner.
  • Gradual migration: the underrated one. If you're stuck on an old framework, you can't rewrite the whole app in one go. You can replace one route at a time while the old app keeps running. Martin Fowler calls this a strangler fig, and Cam Jackson lists incremental upgrades among the main benefits of micro-frontends.
  • Fault isolation: when one slice crashes, the shell can catch the error, show a fallback for that area and keep the rest of the page working. That needs an error boundary in the shell. It doesn't come for free.
Two frontend teams work side by side on separate parts of the interface while a large monitor shows UI pieces being assembled into one product.
Independent deploys help only when each team owns a clear slice and the shell gives that slice a stable place to plug in.

What you pay for it

This is the part conference talks tend to skip. None of these costs is a dealbreaker on its own. Each one needs somebody to own it.

Duplicate code in the download

Every slice builds separately, so every slice can bundle its own copy of the same libraries. Cam Jackson lists payload size as the first downside: independently built bundles "can cause duplication of common dependencies." Module Federation's shared scope helps, but only while teams keep their versions inside compatible ranges. Without a bundle size check in CI, nobody notices until the page gets slow.

The design system becomes a meeting point

Users expect one product, so every slice needs the same buttons, colors and spacing. Ship the component library as an npm package and each team upgrades on its own schedule, so for a while the page shows three versions of the same button. Share it at runtime and you need a versioning policy. Either way, the design system is now something every team depends on, which is exactly the kind of coupling you split up to escape.

State that crosses slices

The teams are separate. The user isn't. The cart badge in the shell needs to know when checkout adds an item, and logging out in one slice has to log you out everywhere. The usual tools are custom DOM events, a small event bus or a shared store, and every one of them is a contract. Treat cross-slice events like a public API: name them, type their payloads, version them and write down who listens. Otherwise one team renames a field, another team's badge stops updating, and there's no error anywhere to tell you why.

Version skew

Teams deploy whenever they like, so at any moment the shell and its remotes come from different builds. If the shell expects a module that the latest remote deploy renamed, users get a runtime error that never showed up on anyone's laptop. With strictVersion, webpack throws a runtime error when a required shared version isn't available, which beats a silent mismatch but still has to be handled. If a remote's entry file fails to load, webpack rejects with a ScriptExternalLoadError. You want contract tests between the shell and each remote, plus a fallback UI for when a remote won't load.

Load time

A statically bundled app knows all its code at build time. A federated app fetches the shell, then each remote's entry file, then the modules it actually needs, and some of those requests can't start until the previous one finishes. Preloading remote entries and caching them on a CDN helps a lot. It's still work you didn't have before.

More pipelines, more places to look

Ten slices means ten pipelines, ten sets of cache rules and ten places where errors land. Cam Jackson puts it plainly: with micro-frontends you're "opting to create many small things rather than one large thing." Before you go to production, make sure every error log and trace carries the slice name and version, so a bug report doesn't start with an hour of guessing which build was live.

Too many frameworks

Independent teams can pick their own framework, and that freedom is easy to overuse. In October 2020 Thoughtworks put micro frontend anarchy on Hold: mixing several frameworks in one page, unless it's part of a deliberate migration. They say some things should stay the same across teams, like the styling approach and how components are integrated, and leave it to each organization to decide whether to standardize state management, data fetching and build tooling too.

Two engineers trace a frontend bug across several monitoring screens showing traces, dependency blocks and network timelines.
Once the UI is assembled at runtime, debugging moves out of one codebase and into traces, versions, caches and the contracts between slices.
The complexity just moves

Splitting the frontend leaves the total complexity about where it was. It moves out of the source code and into contracts, pipelines and monitoring. If nobody owns those, you end up with a distributed monolith: teams still can't ship alone, and now there's a distributed system to run as well.

An Angular host with React modules: what to plan for

The setup I mentioned at the start had this shape: an Angular shell that owns routing and login, with React modules that each deploy on their own. It's a common shape for a framework migration, because the old app keeps running while new areas arrive as React. If you're about to build something similar, these are the questions to answer before the first remote goes live.

  • Who owns the shell? The shell is a product with its own roadmap: routing, auth, layout and the list of shared dependencies. If it belongs to everyone, it belongs to no one, and every remote team ends up patching it.
  • What goes on the shared list? Two different build setups have to agree on which libraries are shared and at which versions. Start with the libraries that break when they load twice, like React, and keep the list short.
  • How do slices talk? Pick one mechanism, write the event names and payloads down, and review changes to them the way you'd review an API change.
  • How do you upgrade the host? A major Angular upgrade in the shell means checking that every remote still mounts and every shared version still lines up. Budget time for that each time.
  • What happens when a remote is down? Decide the fallback early. Users should see "this section couldn't load" in one box while the rest of the page keeps working.

None of this is exotic. It's ordinary engineering work, and each piece needs an owner and time in the plan before the first deploy. The first incident is a bad time to find out nobody had it.

When to skip micro-frontends

The clearest sign you don't need them: your pain isn't about many teams blocking each other. If it comes from somewhere else, micro-frontends add cost without touching the cause.

  • One small team. If the whole frontend team fits in one video call, you don't have a coordination problem. You have a codebase to organize. Feature folders and enforced import rules get you most of the way.
  • A small app. A handful of routes doesn't need a handful of pipelines. The setup would end up bigger than the product.
  • A monorepo with boundaries would do. With Nx you tag projects and let the lint step fail when one imports something it shouldn't (module boundary rules), and nx affected runs only the tasks a change touches. You get clear ownership and faster CI with one build and no runtime composition bugs. Refactoring across one repo is also far easier than across ten.
  • The basics are shaky. If CI is flaky, monitoring is thin or teams already struggle to agree on interfaces, splitting makes every one of those problems bigger. Fix them first.

The backend has the same debate. The questions in Monolith, Modular Monolith, Microservices carry over almost word for word: do your teams need separate release schedules, do failures need to stay contained, and do teams really own their areas? If the answers are mostly no, a modular frontend in one repo is the safer bet. For the backend side of the bill above, see The True Cost of Microservices.

Try the modular monolith first

A frontend monorepo with per-team packages, lint-enforced boundaries and CI that only runs what changed gives teams much of the ownership they're asking for. Before you reach for Module Federation, check whether clearer boundaries in your current repo fix the actual pain. Martin Fowler gives the same advice for services in MonolithFirst.

Match it to the shape of your teams

The most useful question here is a simple one: how many teams need to ship on their own schedule?

Team shapeWhat usually hurtsWhat to tryWhat it often looks like
One or two frontend teams Messy folders, unclear ownership of shared code. A modular monolith: feature folders, import rules, one deploy. One app (Next.js or similar) with a folder per feature and lint rules on imports.
Several teams, starting to queue for releases Release trains, merge conflicts in shared code, slow CI. A monorepo with per-team packages and CI that runs only what changed. Split out one slice only where the pain is worst. Most features stay in the monorepo. One area with its own release rules, say payments, becomes a remote with its own pipeline.
Many teams with separate roadmaps, often across time zones Some team blocks another team's release every week. Micro-frontends, with a platform team that owns the shell, the shared dependency list and the tooling. A shell run by the platform team and dozens of remotes, each with its own pipeline and a written contract with the shell.

The number to watch is how many teams need separate release schedules. Lines of code matter much less. A big codebase with one team is a reason to organize, and organizing is the cheaper fix.

Whatever you pick, plan to revisit it. A monorepo that fits today may not fit in two years, and that's fine. Put a date in the calendar to ask the question again.

Try this week

  • Count how many times last month one team had to wait for another team's work before it could ship. If it's rare, you don't need micro-frontends yet.
  • Turn on import boundary rules in your current repo and see what they flag.
  • If you already run federated slices, add the slice name and version to every error log.
  • Write down every event that crosses slices, with its payload and who listens to it.
  • Add a bundle size check to CI and look for libraries that load twice.
  • Pick one shared library, your date helper or your design system, and agree on who owns its upgrades.

If you want the same boundary thinking inside a single service, Ports & Adapters covers it from the backend side.

What did you think?

Frequently asked questions

What is a micro-frontend?
A slice of the UI, usually one business area like checkout, that one team builds, tests and deploys on its own. A shell app loads the slices and handles shared parts such as routing, login and navigation, so users still see one product.
When are micro-frontends worth it?
When several teams keep blocking each other's releases and need to ship on separate schedules, or when you want to move an old frontend to a new framework one route at a time. For one or two teams, a modular monorepo usually fixes the same pain for less.
What is Module Federation?
A feature that arrived with webpack 5 in 2020 and is also supported by Rspack. It lets separate builds expose and load each other's modules at runtime. The shell loads each remote from its own URL, and shared libraries like React can be configured to load only once.
What do micro-frontends cost?
Duplicate libraries in the download, a design system every team depends on, state that has to cross slices, version skew between builds deployed at different times, extra requests while the page loads, and more pipelines and logs to run.
Can I mix React, Angular and Vue on one page?
You can, but Thoughtworks put micro frontend anarchy on Hold in its October 2020 Radar. Mixing frameworks makes sense during a planned migration. Otherwise, agree on shared choices for styling and how components plug into the page.