Skip to content
← All posts
Build noteNovember 2026

Breaking up a frontend monolith with Nx and Module Federation

2 hosts, 7 remotes, one image for every environment, and the CSS lessons on the way.

Our workflow platform started as one front-end application. That was the right call while one team built it. It stopped being the right call once three product teams wanted to ship their own screens inside it, each on its own schedule. Every release of anything meant a release of everything, and a mistake in one corner could hold up all the others. I led the move to Nx and Module Federation to fix that.

The shape

The platform is now 2 hosts and 7 remotes. A host is the shell people sign in to: it owns authentication, the top-level routes and the navigation. A remote is an independently built and deployed part of the product, loaded by the host at run time with webpack Module Federation. Nx keeps the whole set in one workspace, with shared tooling and clear boundaries between projects.

The same remote can live in more than one host. The workflow designer, for example, is mounted by both hosts, so it is built once and shows up wherever it is needed. Each remote loads in under 2 seconds.

Share as little as possible

Module Federation lets a host and its remotes share libraries at run time. It is tempting to share a lot. We share only React, React DOM, the router and Redux as singletons. Everything else, including the canvas library, the query clients and the UI kit, is bundled into each remote.

We learned that the hard way. Sharing an icon library across the federation boundary failed at load time, and the failure only showed up in the composed app, never in a remote on its own. Sharing less made each remote heavier by a little and the whole system far more predictable.

One image for every environment

A build that bakes in its API address has to be rebuilt for every environment. Instead, each remote loads its own small runtime config file from its own origin when it starts. One image runs in every environment, from development through QA, UAT and Sandbox, and only the config differs. That alone took a whole class of "works in QA, broken in UAT" problems off the table.

Sign-in works the same way across the boundary. The host owns the session. A remote asks the host for request headers on every call and forwards only the ones its own API accepts, so no remote ever handles a login.

CSS that stays home

Styles leaking between a host and its remotes was the most persistent problem. The host's utility classes kept winning over a remote's, and a remote's styles could reach into the host. The fix had to come from both sides:

  • every remote's selectors carry a prefix and live under a root class,
  • the remote's utilities are not put in a cascade layer, so the host's layered styles cannot outrank them,
  • and the host has a rule that skips remote subtrees entirely.

After that, each team could style its screens without checking what the others had done.

What broke on the way

  • A failed load must not be cached. One 404 while loading a remote stuck for the life of the page. Remotes now resolve through the entry the host already registered, so a retry actually retries.
  • Shared state needs a reset. A view that kept its store after it closed could show the next user the last user's data. Stores that hold user data are cleared on unmount.
  • Contracts beat conventions. Each remote talks to its own API with the host's headers, and that boundary is written down. Teams stopped needing to know each other's internals.

The result

Three product teams now plug their modules into the shared host and release them on their own. A change to one remote ships without rebuilding the others, the host stays small, and new product areas start as a new remote instead of a new branch of the monolith. I also wrote the runbooks and migration tooling other developers use to repeat the process.

What it unlocked

This was the project that moved me from building features to shaping how several teams build together. Micro-frontends are as much an organisational tool as a technical one: the boundaries you draw in the code become the boundaries teams work within, so they are worth drawing carefully.