Introduction: Why Micro-Frontends in 2025?
As web applications grow larger and teams become more distributed, the traditional monolithic frontend architecture becomes harder to scale. Enter micro-frontends — the 2025-ready solution that brings backend microservices thinking to the frontend world.
Micro-frontends allow different teams to work independently on isolated UI components, which are then stitched together at runtime. This enables:
- Faster deployment cycles
- Independent scaling of frontend parts
- Team autonomy across tech stacks (e.g., React, Vue, Angular)
At the core of this revolution is Webpack 5’s Module Federation Plugin, which allows independently deployed builds to share code dynamically.
What is Module Federation?
Module Federation is a feature in Webpack 5 that enables one JavaScript application (host) to dynamically load code from another (remote) at runtime.
Key Features:
- Load remote components/apps on demand
- Share dependencies to avoid duplication
- Enable code splitting across teams
- Works with different JS frameworks
Use Case Scenario
Let’s say you’re building a dashboard app in React, but your analytics module is handled by another team using Vue. You don’t want to tightly couple the two.
With Webpack Module Federation, you can load the Vue-based analytics micro-frontend into the React host — all without bundling it directly.
Project Structure Overview
We’ll build two apps:
app-shell(Host) – React dashboard shellanalytics-app(Remote) – Vue analytics micro-frontend
/app-shell (React)
webpack.config.js
src/
bootstrap.js
/analytics-app (Vue)
webpack.config.js
src/
main.js
Step 1: Setting Up the Remote App (Vue)
Install Vue + Webpack in the analytics-app:
npm init vue@latest
cd analytics-app
npm install
Install dependencies for Webpack configuration:
npm install -D webpack webpack-cli webpack-dev-server html-webpack-plugin
Create a webpack.config.js:
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ModuleFederationPlugin = require('webpack').container.ModuleFederationPlugin;
const path = require('path');
module.exports = {
mode: 'development',
devServer: {
port: 8081,
},
entry: './src/main.js',
output: {
publicPath: 'http://localhost:8081/',
},
plugins: [
new ModuleFederationPlugin({
name: 'analytics_app',
filename: 'remoteEntry.js',
exposes: {
'./Analytics': './src/components/Analytics.vue',
},
shared: require('./package.json').dependencies,
}),
new HtmlWebpackPlugin({ template: './public/index.html' }),
],
};
Step 2: Expose a Vue Component
Create src/components/Analytics.vue:
Real-Time Analytics
This component is loaded remotely via Module Federation.
Step 3: Set Up the Host App (React)
Now let’s set up the main container app.
npx create-react-app app-shell
cd app-shell
npm install -D webpack webpack-cli webpack-dev-server html-webpack-plugin
In webpack.config.js of app-shell:
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ModuleFederationPlugin = require('webpack').container.ModuleFederationPlugin;
const path = require('path');
module.exports = {
mode: 'development',
devServer: {
port: 8080,
},
entry: './src/bootstrap.js',
output: {
publicPath: 'http://localhost:8080/',
},
plugins: [
new ModuleFederationPlugin({
name: 'app_shell',
remotes: {
analytics_app: 'analytics_app@http://localhost:8081/remoteEntry.js',
},
shared: require('./package.json').dependencies,
}),
new HtmlWebpackPlugin({ template: './public/index.html' }),
],
};
Update src/bootstrap.js:
import('./App');
Update src/App.js:
import React from 'react';
// Lazy load the remote Vue component
const Analytics = React.lazy(() => import('analytics_app/Analytics'));
function App() {
return (
Host Dashboard
Loading Analytics... }>