Hint
Single-SPA is a router/lifecycle orchestrator; Module Federation is a module-sharing mechanism — they solve different layers
Single-SPA is a JavaScript framework that acts as a top-level router for microfrontends. It manages application lifecycle hooks (bootstrap, mount, unmount) and decides which MFE is active based on the URL.
import { registerApplication, start } from 'single-spa';
registerApplication({
name: '@org/checkout',
app: () => import('@org/checkout'),
activeWhen: ['/checkout'],
});
start();
Module Federation (Webpack 5) is a module loading mechanism — it lets one app dynamically import code from another at runtime, sharing dependencies efficiently.
Key differences:
| Single-SPA | Module Federation | |
|---|---|---|
| What it solves | Routing & lifecycle | Module sharing |
| Framework-agnostic | Yes | Webpack-only |
| Dependency sharing | No | Yes (singleton) |
| Partial page embedding | Hard | Easy |
They are often used together: Single-SPA orchestrates routing, Module Federation handles runtime code sharing.