Microfrontends: when splitting the UI is worth it

The same trade as microservices, played out in the browser — with one extra complication nobody warns you about: every piece has to load into the same page, at the same time, and still feel like one product.

The problem it solves

Microfrontends solve an organisational problem, not a technical one. The symptom is always the same: several teams share one frontend repository, and shipping has become a negotiation.

  • A release train, because nobody can deploy without everyone else's work being ready.
  • A merge queue that is permanently full.
  • One team's failing test blocking four teams' features.
  • An upgrade nobody performs because it would touch every page at once.

If none of those describe you, stop here. A single well-structured frontend with clear module boundaries and lazy-loaded routes gives you most of the benefit and none of the cost. I have seen more projects damaged by premature splitting than by a monolith that got slightly large.

The test Count the teams that need to deploy the frontend independently. If the answer is one, you do not have this problem. Independent deployability is the only thing microfrontends actually buy, and you pay for it whether or not you use it.

Four ways to compose a UI

"Microfrontend" covers several very different architectures. They are not interchangeable.

Approach Composed at Independent deploy? Reality
Packages Build time No Each team publishes a library; the shell rebuilds to pick it up. Simple and safe, but a release still needs a shell build, so it does not solve the deployment problem.
iframes Run time Yes Total isolation, which is both the feature and the problem. Routing, modals, sizing and shared auth all become work. Genuinely good for embedding something foreign.
Web components Run time Yes Framework-neutral, real style encapsulation via shadow DOM. Awkward when you need rich data across the boundary, since attributes are strings.
Module federation Run time Yes The shell loads code from another deployed bundle at run time, sharing framework instances. The most capable, and the one with the sharpest edges.

Shell and remotes

The run-time model that most teams land on: a thin shell owns the frame — the layout, navigation, authentication and routing — and loads remotes on demand. Each remote is a separately built, separately deployed application.

Shell layout · navigation · auth · routing owns nothing a feature team would want to change Orders team A · own pipeline orders.example.com Billing team B · own pipeline billing.example.com Support team C · own pipeline support.example.com loaded at run time, only when the route is visited
Each remote deploys on its own schedule. The shell discovers the new version on the next page load, with no rebuild.

The shell should stay boring and almost empty. Every piece of business logic that creeps into it becomes a thing all teams must coordinate on, which is precisely what you split up to avoid.

Remotes must fail softly A remote is fetched over the network at run time, so it can be slow, cached stale, or missing entirely during a deploy. Wrap every remote in an error boundary with a retry. Without one, a failed fetch of the billing bundle blank-screens the whole application — including the five sections that were fine.

Shared dependencies and version skew

This is where the real difficulty lives. Three remotes each built with their own copy of a framework means the user downloads it three times, and — worse — you get three separate framework instances, each with its own injection context and its own idea of global state.

So the framework is declared shared: loaded once, by whichever part loads first, and reused. Which immediately raises the question nobody enjoys: what if the versions differ?

WITHOUT SHARING Orders + framework Billing + framework Support + framework three downloads, three instances, three states SHARED SINGLETON Orders Billing Support framework (one copy)
Sharing is not only a size optimisation. Two instances of a framework in one page break anything that relies on a single registry.

Practical rules that keep this manageable:

  • Mark the framework and the router as singletons. Two routers fighting over the same URL is a genuinely baffling bug to debug.
  • Agree a version window, and enforce it in CI. Not "everyone upgrades on the same day" — that recreates the release train — but "everyone is within one minor version", checked automatically.
  • Decide loudly what happens on a mismatch. Silently loading two copies produces symptoms that look like anything but a version problem. Warning at startup saves days.
  • Do not share your own code across remotes. A shared utility package is a shared deploy dependency wearing a disguise.

Who owns the URL

Two routers now exist: the shell's, and each remote's. The split that works is simple and worth stating explicitly:

/orders/*     // shell: this prefix belongs to the orders remote
  /orders/42  // remote: everything after the prefix is mine
  /orders/new

The shell matches a prefix and hands over. It must not know that /orders/42/refund exists — the moment it does, adding a page requires a shell deploy.

Deep links are the acceptance test Paste a deep URL into a fresh tab. The shell must boot, authenticate, load the right remote and land on the right screen. If that works, routing ownership is correct. If it only works by clicking through from the home page, a remote is depending on state the shell set up earlier.

Looking like one product

Users do not know or care that four teams built the page. If the buttons are three different blues, the architecture has leaked into the product.

  • Design tokens, not a component library, are the hard dependency. Colours, spacing and type as CSS custom properties published centrally. A remote reads var(--brand) and cannot drift.
  • Scope styles, always. Shadow DOM, CSS modules, or a per-remote class prefix. Global selectors from one remote reaching into another is the worst class of bug here: it appears only when both are on screen, which no single team's test suite covers.
  • Own the shared chrome in the shell. Header, navigation, toasts, modals. Three implementations of a toast is how you end up with three stacking contexts fighting.
  • Version the design system, do not pin it. Remotes should be able to take a token update without a coordinated release.

The honest costs

Everything above is manageable. The costs below are real and permanent, and worth stating before a team commits:

  • Local development is harder. Working on one remote means running the shell too, against either local or deployed versions of the others.
  • End-to-end tests have no natural home. A journey crossing three remotes belongs to no team, so it rots unless someone is explicitly assigned it.
  • Payload goes up, not down. Shared dependencies help, but a shell plus three remotes is more bytes and more requests than one optimally bundled app.
  • Debugging crosses repositories. A stack trace from a federated bundle points at code that lives somewhere else, built by a pipeline you may not have access to.
  • Upgrades need coordination anyway. A major framework upgrade touches every remote. You bought independent deploys, not independent dependencies.
What I would do again Start with one well-structured application and lazy-loaded feature modules. Keep the boundaries clean — each feature owning its own routes, state and API client — so that if the organisation grows into needing independent deploys, extracting a remote is mechanical rather than a rewrite. The boundary is the valuable part. The separate deployment is just what you do with it once the pain is real.

← All articles