Mastering Micro-Frontends with Module Federation in 2026: Patterns & Pitfalls
As engineering teams grow beyond 50+ developers, monolithic frontend repositories become major deployment bottlenecks. Long CI build times, merge conflicts, and risky deployments push teams toward Micro-Frontend Architectures.
Using Webpack 5 / Rspack Module Federation, teams can independently build, test, and deploy separate frontend micro-apps that dynamically stitch together at runtime.
📐 Micro-Frontend Architecture Overview
┌─────────────────────────────────────────────────────────────┐
│ Host Shell Application │
└──────────────┬───────────────────────────────┬──────────────┘
│ │
▼ ▼
┌─────────────────────────────┐ ┌─────────────────────────────┐
│ Remote Micro-App A │ │ Remote Micro-App B │
│ (Checkout / Payment Team) │ │ (User Dashboard / Profile) │
└─────────────────────────────┘ └─────────────────────────────┘
Config Setup (Module Federation)
In your Remote App's rspack.config.js or webpack.config.js:
const { ModuleFederationPlugin } = require('@module-federation/enhanced/rspack');
module.exports = {
name: 'checkoutApp',
filename: 'remoteEntry.js',
exposes: {
'./CheckoutButton': './src/components/CheckoutButton.tsx',
'./PaymentModal': './src/components/PaymentModal.tsx',
},
shared: {
react: { singleton: true, requiredVersion: '^19.0.0' },
'react-dom': { singleton: true, requiredVersion: '^19.0.0' },
},
};
In your Host Shell Application:
module.exports = {
name: 'hostShell',
remotes: {
checkoutApp: 'checkoutApp@https://checkout.yourdomain.com/remoteEntry.js',
},
shared: {
react: { singleton: true },
'react-dom': { singleton: true },
},
};
Dynamic Runtime Consumption in React
import React, { Suspense } from 'react';
// Dynamically import remote component across CDN
const RemoteCheckoutButton = React.lazy(() => import('checkoutApp/CheckoutButton'));
export function CartSummaryPage() {
return (
<div className="p-6 max-w-4xl mx-auto">
<h1 className="text-2xl font-bold mb-4">Your Shopping Cart</h1>
<Suspense fallback={<div className="animate-pulse h-10 bg-gray-200 rounded"/>}>
<RemoteCheckoutButton totalAmount={149.99} currency="USD" />
</Suspense>
</div>
);
}
Crucial Production Guidelines
-
Strict Version Lock: Always mark core libraries (
react,react-dom) assingleton: trueto prevent loading multiple React instances into browser DOM memory. - Resilient Fallbacks: Wrap every remote micro-frontend component in a React Error Boundary so an outage in one remote service doesn't crash the host application.
- Decoupled CI/CD: Ensure every micro-frontend repository has its own independent GitHub Actions deployment pipeline.
✍️ Authored by Lakshan Muruganandam
Lakshan Muruganandam is a software engineer specializing in frontend architecture, micro-services, and developer tooling.
- GitHub: github.com/lakshanmuruganandam
- X / Twitter: @itsmeladdoo
- Official Tech Blog: lakshanmuruganandam.hashnode.dev
Top comments (0)