Micro Frontends vs Modular Monolith: How to Choose
A modular monolith keeps one build and enforces domain boundaries with import rules. Micro frontends split the product into separately deployed bundles that a shell loads at runtime. This is what happens inside each one, and how I would measure whether the second is worth it.
By Oleksii Vasylenko, Technical Lead · Published · Updated · 13 min read
Where this comes from. Leading the monolith-to-micro-frontend migration at PropertyGuru for four product teams: ownership split by business domain, Webpack Module Federation for runtime composition, and one payment service behind a contract all four teams consumed.
Micro Frontends vs Modular Monolith: The Short Answer
The micro frontends vs modular monolith question comes up whenever a frontend codebase gets big enough that several teams are waiting on each other. My answer, after doing one of these migrations for real: stay with a modular monolith if your teams can share one release train without measurable delay. Move to micro frontends when several durable teams own separate business domains and a coordinated frontend release is already the slowest step in shipping.
Both designs can enforce module boundaries. Only one of them turns the browser into a distributed system, with separately deployed bundles, versioned runtime contracts, remote loading states, and a platform that somebody has to own. Repository size is a poor signal. A codebase can contain millions of lines and still work as one deployment when ownership and release decisions line up.
The rest of this article explains what each option does under the hood, then walks through the PropertyGuru migration where four product teams went from a release cycle measured in weeks to one measured in days. The mechanics matter, because most of the arguments I hear for or against micro frontends are really arguments about a specific failure mode that only shows up once you know how the pieces load.
What a Modular Monolith Looks Like Inside
A modular monolith is one deployable application with boundaries enforced inside the codebase. Each domain owns its routes, state, API clients, tests, and internal components. Other domains can only import what a domain publishes through its index file. The build, the dependency graph, server rendering, local development, and rollback all stay shared, which is what keeps them simple.
The boundary has to be enforced by tooling, because a convention that lives in a wiki does not survive the third new hire. The cheapest version is an ESLint rule that forbids deep imports across domain folders. Anything a domain wants to share goes through its public entry point, and the rule fails CI if someone reaches past it:
// domains/checkout/.eslintrc.js
module.exports = {
rules: {
'no-restricted-imports': ['error', {
patterns: [
{
group: ['@app/search/*', '!@app/search'],
message: 'Import from the search domain\'s public index only.',
},
{
group: ['@app/billing/*', '!@app/billing'],
message: 'Import from the billing domain\'s public index only.',
},
],
}],
},
}Do not confuse this with folders named components, hooks, and services. Those are technical layers, and one customer feature cuts across all of them, so no team can own a feature end to end. Domain modules such as search, checkout, billing, and account create vertical ownership. Tooling enforces the import rule, but the real control is that one team reviews and releases changes to one capability.
- One artifact, one dependency graph, one version in production at a time.
- Cross-domain imports go through a published index and are checked in CI.
- Rendering and application state live in one runtime, so there is no remote to wait for.
- A release can still contain changes from several teams, which is the whole cost of this design.
What Module Federation Does at Runtime
Micro frontends divide the product into separately built and deployed applications that appear to the user as one interface. A shell owns top-level navigation, identity, layout, error boundaries, and telemetry. Domain applications own routes or vertical slices. Composition can happen on the server, at build time, through browser routing, or at runtime. The runtime version is what most people mean today, and Webpack Module Federation is the usual implementation, so that is the one I will open up.
Each remote is built with ModuleFederationPlugin. The plugin gives the build a name, a list of modules it exposes, and a shared map of dependencies it is willing to share with whoever loads it. The output includes a small file, conventionally remoteEntry.js, which is a container with two methods: init and get.
new ModuleFederationPlugin({
name: 'payments',
filename: 'remoteEntry.js',
exposes: {
'./CheckoutRoute': './src/routes/CheckoutRoute',
},
shared: {
react: { singleton: true, requiredVersion: '^18.2.0' },
'react-dom': { singleton: true, requiredVersion: '^18.2.0' },
'@company/design-tokens': { singleton: true },
},
})When the shell needs a module from that remote, four things happen in order. The shell initialises its shared scope with __webpack_init_sharing__('default'). It loads remoteEntry.js as a script, which registers the container on window. It calls container.init(__webpack_share_scopes__.default), passing its shared scope so the remote can see which versions of React and the design tokens are already available. Then it calls container.get('./CheckoutRoute'), which returns a factory for the module. Webpack splits this into an asynchronous load phase and a synchronous evaluation phase, so evaluation order is the same whether a module is local or remote.
The shared map is where version negotiation happens. Each side declares a requiredVersion (taken from its own package.json by default). A singleton: true entry means only one instance may be loaded across every build on the page; if the shell already provides a React that satisfies the remote's range, the remote uses it. If the range is not satisfied, webpack logs a warning and the remote falls back to its own copy, which for React means two copies, two hook contexts, and the "Invalid hook call" error that has cost every team doing this at least one afternoon. The host provides overrides to remotes it loads, but sibling remotes cannot override each other.
One more mechanic bites early. Because shared modules are resolved asynchronously, the shell's own entry point cannot import React synchronously before the share scope exists. The error is "Shared module is not available for eager consumption". The fix is an async boundary: the entry file does nothing but import('./bootstrap'), and the real application starts inside that dynamic import. Or you mark the dependency eager: true and accept it in the initial chunk.
What a Remote Load Failure Looks Like
A remote can fail in ways a monolith cannot. The remoteEntry.js request can 404 because a deploy removed the version the shell was pointing at. The script can load but a module can be missing, which surfaces as a TypeError: fn is not a function from deep inside webpack's runtime rather than a readable message. The container can initialise twice if two parts of the shell race to load it. And the shell can be a version ahead of a remote that still expects an old capability.
So every remote mount point needs a loading state, a timeout, an error boundary, and a decision about what to render when the boundary trips. In React that is React.lazy around the federated import, Suspense for the loading state, and an error boundary that knows which remote failed:
const CheckoutRoute = React.lazy(() => import('payments/CheckoutRoute'))
<RemoteErrorBoundary
remote="payments"
fallback={<CheckoutUnavailable retryHref="/checkout" />}
>
<Suspense fallback={<RouteSkeleton />}>
<CheckoutRoute />
</Suspense>
</RemoteErrorBoundary>The boundary is where the product decision lives. Checkout should fail closed with a clear message and a way to try again. An optional recommendations panel can disappear without anyone noticing. Whatever the policy, the boundary reports which remote and which release failed, or the on-call engineer is left with a shell error and no owner.
Distribution reduces blast radius only when failure is isolated this way. A remote that throws during shell startup, before any boundary exists, still takes the whole page down. I have seen a lot of micro frontend rollouts where the isolation was assumed rather than built.
Five Questions That Decide
Count durable teams first. Two teams temporarily touching one product do not justify a permanent runtime boundary. Then measure release contention. "Deployments feel slow" is weak evidence. Median wait time for a change to reach production and the number of blocked releases per month are useful. Check domain stability next: a boundary that moves every sprint turns ordinary refactoring into cross-application migration.
Fourth, test end-to-end ownership. A team that owns a React remote but depends on another group for every API change cannot release independently, so the remote buys nothing. Fifth, price the platform work: artifact hosting, manifests, compatibility checks, local composition, source maps, observability, fallbacks, security policy, on-call. If nobody owns that platform, each product team builds a different version of it.
- Are at least three stable teams shipping distinct business domains?
- Does frontend release coordination create delay you can put a number on?
- Can each team own its route through the API and data boundary?
- Can the organisation operate and observe several web artifacts? Who is on call for the shell?
- Will the proposed domain split still make sense in three years?
Performance Cost of Runtime Composition
A modular monolith deduplicates dependencies at build time and optimises one route graph. Micro frontends can ship duplicate framework, utility, and design-system code unless the shared configuration is controlled and audited. Every runtime remote is at least one extra network request for remoteEntry.js plus the chunks it pulls in, and that request happens after the shell has already parsed and started.
Measure JavaScript bytes and remote-entry latency per route, not only the shell bundle. The number that surprised us was how much of a route's time was the sequential chain: shell loads, shell decides which remote it needs, remote entry loads, remote chunks load. Preloading the remote entry for the likely next route recovers most of it, but that is one more thing the platform has to do.
How the PropertyGuru Migration Was Set Up
At PropertyGuru I led a monolith-to-micro-frontend migration for four product teams. Before the split, all four teams committed to one frontend repository and shipped through one release. Any team's change could hold the release, and a rollback rolled back everyone. The practical effect was that a change waited for the next coordinated release window, and the cycle was measured in weeks.
The decision that mattered was where to draw the lines. We split ownership by business domain, listings, payments, analytics, and agent tools, rather than by UI layer. Each team received a vertical slice: its routes, its API calls, its state, its tests. A shell owned navigation, authentication, layout, and telemetry, and loaded each domain as a Module Federation remote.
We kept the shared foundation small on purpose: design tokens, authentication, navigation, and strict service contracts. Each shared dependency was a singleton in the shell's shared map, and each one was a coordination point we had to justify. Payments was the interesting case. All four teams needed to take a payment, and the old monolith had several copies of that logic. We built one payment service with a contract the four teams consumed, so a change to payment handling was one change in one place rather than four pull requests in four domains.
After the split, a team deployed its remote on its own pipeline. The shell pointed at a versioned remote entry, so promoting a new version of the listings remote did not touch payments or analytics, and rolling it back was a pointer change. That is how the release cycle went from weeks to days. It was not Module Federation that did it. It was that the deployment boundary finally matched who was accountable for the code.
Migrating Without a Rewrite
Start by creating domain ownership inside the monolith. Move routes, tests, API access, and state behind explicit boundaries. Add the import rules and remove the cross-domain imports they flag. This work is needed whichever architecture wins, and it tells you whether the organisation can respect boundaries before deployment becomes distributed. If teams cannot keep the ESLint rule green, they will not keep a runtime contract stable either.
Then extract one domain with high release contention and few synchronous dependencies on the others. Route-level extraction is easier to reason about than splitting individual widgets across teams. Keep the old code path available during rollout, compare errors and performance between the two, and prove that an independent rollback works. A migration that begins by federating the design system has picked the most shared code in the product as its first experiment.
- Define domain owners and public interfaces in the existing application first.
- Measure coordination delay before changing deployment topology, so you have a before number.
- Extract one route-level domain behind a feature flag or a reversible routing rule.
- Add remote-specific error reporting, web vitals, release markers, and a rollback procedure with that first remote.
- Expand only after the first domain has released independently in practice, more than once.
Contracts, Security, and Who Owns the Platform
A runtime-loaded remote is executable code entering the product shell. Its origin, manifest, release identity, and allowed capabilities are a security boundary. The shell should load remotes only from approved locations, apply a Content Security Policy that fits the deployment model, and expose narrow capabilities. Handing every remote unrestricted browser storage or a mutable authentication object means one compromised or buggy remote can act as any of them.
Contracts need owners and support windows. A shell capability publishes a version, a compatibility test, and a removal date. Remote teams prove compatibility before promotion rather than after a customer loads the page. Source maps and release identifiers have to resolve an error to one artifact and one owner. Without that, independent deployment turns incidents into a meeting where every team reports that its own build passed.
- Allowlist remote origins and control who can promote a manifest.
- Version shell capabilities and test them against every supported remote version.
- Keep authentication and authorisation decisions behind controlled interfaces, never in a shared mutable object.
- Attach every error and web vital to the exact shell and remote release that produced it.
When to Stop or Reverse
Set success criteria before extraction: release wait time, deployment frequency, rollback scope, route performance, error rate, and engineering time spent on the platform. If autonomy does not improve while runtime cost rises, stop. A technically successful extraction can still be a bad organisational investment.
Reversing is fine. Domains can return to one deployment while keeping the ownership and module boundaries learned during migration. The asset you want at the end is a system whose boundaries match accountability. Whether those modules arrive in one bundle or five is a delivery choice, and it can change as the organisation does.
Decision Matrix
| Question | Modular monolith | Micro frontends |
|---|---|---|
| Deployment | One coordinated artifact | Independent domain artifacts behind a shell |
| Team model | Shared release train is acceptable | Durable, autonomous domain teams |
| Runtime cost | One graph, no remote loading | Remote entries, shared-scope negotiation, possible duplication |
| Failure isolation | Application-level rollback | Per-remote rollback, if error boundaries are built |
| Local development | One environment | Shell, remotes, manifests, and compatibility states |
| Best starting point | Default for most products | When measured coordination cost justifies it |
A modular monolith is often the correct final design, not a stop on the way to micro frontends.
Related reading
The production guide covers shell responsibilities, routing, shared state, Module Federation, observability, and the PropertyGuru migration in more detail.
Read the React micro frontend architecture guide →