A React 19 micro-frontend application built with Nx monorepo, Module Federation, and Bootstrap 5. This application can run as a standalone app or be consumed as a remote module in a host application.
Access the full React application directly:
- URL: https://hemantajax.github.io/mfe-react/
- Features: Complete React app with routing, Bootstrap 5 UI, works independently
Consume this micro-frontend in any host application:
- Remote Entry: https://hemantajax.github.io/mfe-react/remoteEntry.mjs
- Module Name:
reactdemos - Exposed Module:
./Module
- Prerequisites
- Quick Start
- Development Setup
- Production Build
- Deployment
- Module Federation Usage
- Available Scripts
- Project Structure
- Technologies Used
- Testing
- Troubleshooting
Before you begin, ensure you have the following installed:
- Node.js: v18.x or higher
- npm: v9.x or higher
- Git: Latest version
# Check versions
node --version
npm --version
git --version# 1. Clone the repository
git clone https://github.com/hemantajax/mfe-react.git
cd mfe-react
# 2. Install dependencies
npm install
# 3. Start development server
npm start
# 4. Open browser
# Application runs at http://localhost:4201npm installThis will install:
- React 19
- React Router DOM 6.29
- Bootstrap 5.3.8
- Nx 22.x
- Webpack Module Federation
- All development dependencies
# Using npm script
npm start
# Or using Nx directly
npx nx serve reactdemos
# With specific host/port
npx nx serve reactdemos --host=0.0.0.0 --port=4201The application will be available at:
- Local:
http://localhost:4201 - Network:
http://<your-ip>:4201(if host set to 0.0.0.0)
- β Hot Module Replacement (HMR)
- β Fast Refresh for React
- β Source maps for debugging
- β ESLint integration
- β Prettier formatting
- β TypeScript support
# Production build
npm run build:prod
# Or using Nx
npx nx build reactdemos --configuration=productionBuild output location: apps/reactdemos/dist/
- β Code minification
- β Tree shaking
- β Bundle optimization
- β Module Federation setup
- β Source maps (optional)
- β Asset optimization
# Preview the production build
npm run preview
# Or using Nx
npx nx preview reactdemosThis project is configured for automatic deployment to GitHub Pages.
# Build and deploy in one command
npm run deployThis command will:
- Run production build (
npm run build:prod) - Deploy to
gh-pagesbranch - Update GitHub Pages site
# 1. Build for production
npm run build:prod
# 2. Deploy using gh-pages
npx gh-pages -d apps/reactdemos/dist -b gh-pages -m 'Deploy reactdemos micro-frontend'- Go to your repository settings
- Navigate to Pages section
- Set source to
gh-pagesbranch - Set folder to
/ (root) - Save and wait 2-3 minutes
# Check if remote entry is accessible
curl -I https://hemantajax.github.io/mfe-react/remoteEntry.mjs
# Expected: HTTP/2 200In host application's module-federation.config.js:
module.exports = {
name: 'host',
remotes: {
reactdemos: 'reactdemos@https://hemantajax.github.io/mfe-react/remoteEntry.mjs',
},
};React Lazy Loading (Recommended):
import React, { Suspense } from 'react';
const RemoteReactDemos = React.lazy(() => import('reactdemos/Module'));
function App() {
return (
<div className="container">
<h1>Host Application</h1>
<Suspense fallback={<div>Loading ReactDemos...</div>}>
<RemoteReactDemos />
</Suspense>
</div>
);
}With React Router:
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import React, { Suspense } from 'react';
const RemoteReactDemos = React.lazy(() => import('reactdemos/Module'));
function App() {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<Home />} />
<Route
path="/reactdemos/*"
element={
<Suspense fallback={<div>Loading...</div>}>
<RemoteReactDemos />
</Suspense>
}
/>
</Routes>
</BrowserRouter>
);
}Create src/declarations.d.ts in host app:
declare module 'reactdemos/Module' {
const Module: React.ComponentType;
export default Module;
}Ensure your host application shares these dependencies:
shared: {
react: { singleton: true, requiredVersion: '^19.0.0' },
'react-dom': { singleton: true, requiredVersion: '^19.0.0' },
'react-router-dom': { singleton: true, requiredVersion: '6.29.0' },
}npm start # Start development server
npm run preview # Preview production build
npm test # Run tests
npm test:watch # Run tests in watch mode
npm test:coverage # Generate test coverage reportnpm run build # Development build
npm run build:prod # Production buildnpm run deploy # Build and deploy to GitHub Pages
npm run predeploy # Pre-deployment hook (runs build:prod)npm run lint # Lint code
npm run lint:fix # Fix linting issues
npm run format # Format code with Prettier
npm run format:check # Check code formattingnpm test # Run unit tests
npm run e2e # Run end-to-end tests
npm run e2e:headless # Run e2e tests in headless modenpm run nx:graph # Visualize project dependencies
npm run nx:reset # Reset Nx cache
npx nx show project reactdemos # Show project detailsnpm run affected:build # Build affected projects
npm run affected:test # Test affected projects
npm run affected:lint # Lint affected projects
npm run affected:e2e # E2E test affected projectsmfe-react/
βββ apps/
β βββ reactdemos/ # Main application
β βββ src/
β β βββ app/ # React components
β β βββ assets/ # Static assets
β β βββ main.tsx # Application entry
β β βββ index.html # HTML template
β βββ webpack.config.js # Webpack + Module Federation
β βββ project.json # Nx project configuration
β βββ tsconfig.json # TypeScript config
βββ docs/ # Documentation
β βββ DEPLOYMENT_GUIDE.md
β βββ HOST_SHELL_MFE_SETUP.md
β βββ GITHUB_PAGES_DEPLOYMENT.md
β βββ REMOTE_MFE_SETUP.md
βββ package.json # Dependencies & scripts
βββ nx.json # Nx workspace config
βββ tsconfig.base.json # Base TypeScript config
βββ HOW_TO_ACCESS_REMOTE.md # Remote usage guide
βββ README.md # This file
| Technology | Version | Purpose |
|---|---|---|
| React | 19.0.0 | UI Framework |
| React Router DOM | 6.29.0 | Routing |
| Bootstrap | 5.3.8 | UI Components & Styling |
| TypeScript | 5.9.2 | Type Safety |
| Nx | 22.0.1 | Monorepo Management |
| Webpack | 5.x | Module Bundler |
| Module Federation | 2.x | Micro-Frontend Architecture |
| Jest | 30.0.2 | Testing Framework |
| Playwright | 1.36.0 | E2E Testing |
| ESLint | 9.8.0 | Code Linting |
| Prettier | 2.6.2 | Code Formatting |
# Run all tests
npm test
# Watch mode
npm run test:watch
# Coverage report
npm run test:coverage# Run e2e tests
npm run e2e
# Headless mode
npm run e2e:headless- Unit Tests: Jest + React Testing Library
- E2E Tests: Playwright
- Coverage: Istanbul
Problem: Port 4201 already in use
# Kill process on port 4201
lsof -ti:4201 | xargs kill -9
# Or use different port
npx nx serve reactdemos --port=4202Problem: Module not found errors
# Clear Nx cache
npm run nx:reset
# Reinstall dependencies
rm -rf node_modules package-lock.json
npm installProblem: Build fails with memory error
# Increase Node memory
export NODE_OPTIONS="--max-old-space-size=4096"
npm run build:prodProblem: TypeScript errors
# Check TypeScript configuration
npx tsc --noEmit
# Fix linting issues
npm run lint:fixProblem: GitHub Pages shows 404
- Verify
gh-pagesbranch exists - Check GitHub Pages settings
- Wait 2-3 minutes after deployment
- Clear browser cache
Problem: Remote entry not loading
# Verify deployment
curl -I https://hemantajax.github.io/mfe-react/remoteEntry.mjs
# Check CORS (should be OK on GitHub Pages)Problem: Cannot load remote module
- Verify remote URL is correct and accessible
- Check browser console for errors
- Ensure shared dependencies are compatible
- Verify
singleton: truefor React packages
Problem: Version conflicts
- Use same React version (19.x) in host and remote
- Set
requiredVersionin shared dependencies - Check for duplicate dependencies
For more detailed information, see:
- HOW_TO_ACCESS_REMOTE.md - Complete guide to consuming this remote
- docs/DEPLOYMENT_GUIDE.md - Detailed deployment instructions
- docs/HOST_SHELL_MFE_SETUP.md - Host application setup
- docs/GITHUB_PAGES_DEPLOYMENT.md - GitHub Pages configuration
- docs/REMOTE_MFE_SETUP.md - Remote MFE configuration
| Resource | URL |
|---|---|
| Live App | https://hemantajax.github.io/mfe-react/ |
| Remote Entry | https://hemantajax.github.io/mfe-react/remoteEntry.mjs |
| Repository | https://github.com/hemantajax/mfe-react |
| Local Dev | http://localhost:4201 |
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License.
This project uses Nx for monorepo management. Learn more:
Install Nx Console extension for better developer experience:
Last Updated: October 31, 2025
Version: 1.0.0
Maintained by: Hemant