Module Federation eXperience: a no-nonsense module federation starter project to unlock your microfrontends architecture journey
MFX Starter is a comprehensive, production-ready microfrontends starter project built with Module Federation. It demonstrates how to build scalable, maintainable microfrontend architectures using multiple frameworks (React, Angular, Svelte) within a single cohesive application.
This project provides a solid foundation for teams looking to implement microfrontends with proper error handling, shared state management, authentication, internationalization, and divergent tooling and testing strategies.
- Module Federation: Built with Rsbuild and Module Federation for seamless microfrontend orchestration
- Multi-Framework Support: React (Host), Angular (Provider), Svelte (Provider)
- Monorepo Structure: npm workspaces for efficient dependency management
- TypeScript First: Full TypeScript support across all applications and packages
- Hot Module Replacement: Lightning-fast development with HMR across all MFEs
- Shared Utilities: Common utilities and components shared across microfrontends
- Consistent Tooling: Unified ESLint, Prettier, and TypeScript configurations
- Testing Options: Jest, Karma/Jasmine, Vitest, and Cypress for full testing coverage
- Error Boundaries: Graceful degradation when remote modules fail
- Authentication: JWT-based authentication with secure token management
- Internationalization: i18next integration for multi-language support
- State Management: Zustand for cross-MFE state sharing
- Security: CSP-ready, secure token storage, and CORS considerations
- Tailwind CSS: Utility-first CSS framework for React and Svelte
- SCSS: Modern CSS preprocessing for Angular
- Responsive Design: Mobile-first approach with consistent breakpoints
- Node.js >= 24.0.0
- npm >= 8.0.0
- Clone the repository:
git clone https://github.com/Barnett-Studios/mfx-starter.git
cd mfx-starter- Install dependencies and build shared packages:
npm install- Set up environment variables:
# Copy environment template files
cp apps/mf_host/.env.example apps/mf_host/.env
cp apps/mf_provider_angular/.env.example apps/mf_provider_angular/.env
cp apps/mf_provider_svelte/.env.example apps/mf_provider_svelte/.env- Start all applications:
npm run start:allHost Application (React):
npm run dev -w mf_hostAngular Provider:
npm run dev -w mf_provider_angularSvelte Provider:
npm run dev -w mf_provider_svelteWhen running individual applications or using the preview:host scripts, you might encounter URLs like host-react.mfx.com, provider-angular.mfx.com, and provider-svelte.mfx.com. To ensure your browser can resolve these custom hostnames to your local development server, you need to add entries to your system's hosts file.
Example hosts file entries:
127.0.0.1 host-react.mfx.com
127.0.0.1 provider-angular.mfx.com
127.0.0.1 provider-svelte.mfx.com
- **Linux/macOS:** `/etc/hosts`
- **Windows:** `C:\Windows\System32\drivers\etc\hosts`Additionally, be aware that when microfrontends load resources from different origins (e.g., the host loading a provider), Cross-Origin Resource Sharing (CORS) policies apply. Ensure your Rsbuild configurations for development servers are set up to allow the necessary CORS headers to prevent resource loading issues. Therefore, the correct values for these hostnames must also be configured in the respective .env files for each project (e.g., apps/mf_host/.env), as commands like builduse cross-env env-cmd -f .env rsbuild build to inject these environment variables, which Rsbuild then uses for CORS configuration.
# Build all applications
npm run build:all
# Build individual applications
npm run build -w mf_host
npm run build -w mf_provider_angular
npm run build -w mf_provider_svelte-
Unique URLs: Each microfrontend's build output (
distfolder) should be deployed to a unique, publicly accessible URL or path (e.g.,https://your-app.com/,https://your-app.com/angular-mfe/,https://your-app.com/svelte-mfe/). -
Host
remotesConfiguration: The host application's Module Federation configuration (module-federation.config.ts) must specify the full URLs to the Module Federation manifest files of the provider microfrontends it consumes. The base URLs for the providers are configurable via .env files. -
Shared Packages: Libraries like
@mfx/shared-utils,react,i18next, andzustandare configured assharedsingletons in Module Federation. This means the host application bundles and provides a single instance of these libraries, which is then consumed by the microfrontends. Changes to these shared packages typically require rebuilding and redeploying the host application.
# Run all tests
npm run test:all
# Run E2E tests
npm run e2e
# Open Cypress Test Runner
npm run cy:openβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MF Host (React) β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ β
β β Navigation β β Auth Module β β Notifications β β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ β
β β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ β
β β Angular Widget β β Svelte Widget β β Shared UI β β
β β (Remote) β β (Remote) β β Components β β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
β
βββββββββββββββββββββββββββββββββββββββ
β Shared Packages β
β β
β βββββββββββββββ βββββββββββββββ β
β β Utils β β UI β β
β β (Zustand, β β Components β β
β β Axios, β β (React) β β
β β i18next) β β β β
β βββββββββββββββ βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββ
Each microfrontend exposes specific modules that can be consumed by the host application:
Host (mf_host):
- Consumes:
AngularWidget,SvelteWidget, routing modules - Provides: Global navigation, authentication, notifications, and shared singleton instances of core libraries (
react,i18next,zustand) and@mfx/shared-utils.
Angular Provider (mf_provider_angular):
- Exposes:
AngularWidget,AngularRoutes - Technology: Angular 20+ with SCSS
- Consumes shared core libraries and
@mfx/shared-utilsfrom the host.
Svelte Provider (mf_provider_svelte):
- Exposes:
SvelteWidget,SvelteRoutes - Technology: Svelte 5+ with Tailwind CSS
- Consumes shared core libraries and
@mfx/shared-utilsfrom the host.
- Shared State: Zustand stores manage global state (authentication, user preferences) and are accessible as singletons across all microfrontends.
- Event System: Custom event dispatcher for **decoupled, fire-and-forget cross-MFE communication.*- Microfrontends dispatch actions (e.g., item added, counter changed) which the host or other MFEs can listen to.
- HTTP Client: Shared Axios instance with authentication and error handling
- Internationalization: Centralized i18next configuration ensuring consistent language across the entire application.
- Error Boundaries: React Error Boundaries wrap each remote module
- Graceful Degradation: Fallback UI when remote modules fail to load
- Global Error Handling: HTTP interceptors catch and handle API errors
- User Feedback: Global notification system for error reporting (triggered by
dispatchNotificationfrom any MFE).
- Build Tool: Rsbuild with Module Federation plugin
- Languages: TypeScript, JavaScript
- Package Manager: npm with workspaces
- React: 19.1.0 (Host application)
- Angular: 20.0.6 (Provider application)
- Svelte: 5.35.4 (Provider application)
- Zustand: 5.0.6 (State management)
- Axios: 1.6.5 (HTTP client)
- i18next: 23.8.2 (Internationalization)
- react-i18next: 13.5.0 (React bindings for i18next)
- Testing: Jest, Karma/Jasmine, Vitest, Cypress
- Linting: ESLint with TypeScript support
- Formatting: Prettier
- Styling: Tailwind CSS, SCSS
- GitHub Actions: Automated testing and deployment
Contributions from the community are warmly welcomed! Please read our Contributing Guidelines before submitting pull requests.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Run the test suite:
npm run test:all - Run linting:
npm run lint:all - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Basic Module Federation setup
- Monorepo with npm workspaces
- Switch to Nx for a better monorepo experience
- Build & deploy GutHub Actions pipeline
- React Host application
- Angular Provider application
- Svelte Provider application
- React Provider application
- Vue Provider application
- Web Components Provider application (Webpack 5)
- Shared utilities and components
- Basic Authentication system mocks
- Error handling and graceful degradation
- Cross-MFE communication via shared event dispatcher
- Consistent i18n and Auth state across MFEs
- Advanced routing with nested microfrontends
- Performance monitoring and analytics
- Advanced caching strategies
- Micro-app deployment strategies
- Integration with popular state management libraries
- Single Sign-On (SSO) integration
- Advanced security features
- Multi-tenant support
- Advanced monitoring and logging
- Performance optimization guides
- CLI tool for generating new microfrontends
- Visual development tools
- Advanced debugging utilities
- Documentation generator
If you encounter any issues or have questions, check the Issues page
Built and maintained by Barnett Studios β building products, teams, and systems that last. Part-time technical leadership for startups and scale-ups.