A microfrontend architecture project demonstrating module federation with React (host) and Svelte (remote) applications, sharing state via RxJS.
- Host App (React): Displays a list of users fetched from JSONPlaceholder API
- Remote App (Svelte): Shows user details in a sliding sidebar
- Shared State: RxJS-based reactive store for user data synchronization
- URL Sync: Selected user ID is synced with the browser URL (
?user=[id])
- 🔄 Module Federation: Webpack 5 module federation for microfrontend architecture
- ⚛️ React Host: Main application with user list
- 🔥 Svelte Remote: Sidebar component for user details
- 📡 Reactive State: RxJS BehaviorSubject for real-time state sharing
- 🔗 URL Synchronization: Browser URL reflects selected user
- 🎨 Modern UI: Beautiful, responsive design with smooth animations
- 📱 Responsive: Works on desktop and mobile devices
microfront-reactive-query/
├── host/ # React host application
│ ├── src/
│ │ ├── App.jsx # Main React component
│ │ ├── App.css # Styles
│ │ ├── userStore.js # Shared RxJS store
│ │ └── index.js # Entry point
│ ├── public/
│ │ └── index.html
│ ├── webpack.config.js
│ └── package.json
├── remote-svelte/ # Svelte remote application
│ ├── src/
│ │ ├── UserDetailSidebar.svelte # Sidebar component
│ │ ├── UserDetailSidebar.js # React wrapper
│ │ ├── userStore.js # Shared RxJS store
│ │ ├── App.svelte # Standalone app
│ │ └── index.js
│ ├── public/
│ │ └── index.html
│ ├── webpack.config.js
│ └── package.json
└── package.json # Root package with scripts
- Install dependencies for all projects:
npm install
cd host && npm install
cd ../remote-svelte && npm install
cd ..Or use the convenience script:
npm run install:allStart both applications simultaneously:
npm run devOr start them individually:
# Terminal 1 - Start the host app (port 3002)
npm run dev:host
# Terminal 2 - Start the remote app (port 3001)
npm run dev:remoteThen open your browser:
- Host App: http://localhost:3002
- Remote App (standalone): http://localhost:3001
-
Host Application (React on port 3002):
- Fetches user list from https://jsonplaceholder.typicode.com/users
- Stores users in RxJS BehaviorSubject
- Displays users in a grid layout
- On user click, updates selected user ID and URL parameter
- Lazy loads the Svelte sidebar component via Module Federation
-
Remote Application (Svelte on port 3001):
- Exposes
UserDetailSidebarcomponent via Module Federation - Subscribes to the shared RxJS store for selected user changes
- Displays detailed user information in a sliding sidebar
- Sidebar can be closed by clicking the close button or backdrop
- Exposes
-
Shared State:
- Both apps use identical
userStore.jswith RxJS BehaviorSubjects - Module Federation ensures singleton pattern for shared dependencies
- Real-time synchronization across microfrontends
- Both apps use identical
-
URL Synchronization:
- When a user is selected, URL updates to
?user=[id] - On page load, checks URL for initial user selection
- Enables deep linking and browser history navigation
- When a user is selected, URL updates to
- React 18: Host application framework
- Svelte 4: Remote sidebar component
- Webpack 5: Module Federation and bundling
- RxJS 7: Reactive state management
- JSONPlaceholder: Fake REST API for user data
Host (React):
remotes: {
remoteSvelte: 'remoteSvelte@http://localhost:3001/remoteEntry.js'
}Remote (Svelte):
exposes: {
'./UserDetailSidebar': './src/UserDetailSidebar.js'
}- Change API endpoint: Modify the fetch URL in
host/src/App.jsx - Styling: Update CSS files in respective apps
- Port numbers: Change ports in webpack configs
- Sidebar width: Adjust width in
UserDetailSidebar.sveltestyles
cd host && npm run build
cd ../remote-svelte && npm run buildMIT