惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Cloudflare Blog
U
Unit 42
F
Fortinet All Blogs
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
Y
Y Combinator Blog
罗磊的独立博客
V
Visual Studio Blog
大猫的无限游戏
大猫的无限游戏
J
Java Code Geeks
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
爱范儿
爱范儿
B
Blog RSS Feed
aimingoo的专栏
aimingoo的专栏
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
Microsoft Security Blog
Microsoft Security Blog
L
LangChain Blog
I
InfoQ
博客园 - 叶小钗
博客园 - 聂微东
Last Week in AI
Last Week in AI

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Setting Up the Remote Project for React Micro Frontends
Aemarajan S · 2026-04-30 · via DEV Community

In the previous guide, we built the Shell Project — the central container that hosts and manages micro frontends. If you missed it, check out Setting Up the Shell Project for React Micro Frontends to get started.

Now, it’s time to build our first Remote Project — the independent micro frontend that the Shell will load dynamically using Webpack Module Federation.

By the end of this post, you’ll have a working remote React app that connects seamlessly with your Shell.

Step 1: Create a React App for the Remote

Just like we did with the Shell, let’s create a new React app for our remote micro frontend:

npx create-react-app mfe1

Enter fullscreen mode Exit fullscreen mode

This will scaffold a fresh React project called mfe1 with all the basics in place.

Step 2: Install and Configure html-webpack-plugin

Just like we did with the Shell, our Remote app also needs Webpack to generate the index.html file and inject the bundled JavaScript automatically. This is especially important because the Remote will expose components that the Shell will later consume.

Let’s add html-webpack-plugin to the Remote project:

npm install --save-dev html-webpack-plugin

Enter fullscreen mode Exit fullscreen mode

Step 3: Configure Module Federation in the Remote App

Now let’s expose modules from the Remote so the Shell can load them dynamically. We’ll add Module Federation to the Remote’s Webpack config.

// webpack.config.js (Remote: mfe1)
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
const path = require("path");

module.exports = {
  entry: "./src/index.js",
  mode: "development",
  devServer: {
    port: 3001,
    historyApiFallback: true,
  },
  output: {
    publicPath: "http://localhost:3001/",
  },
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader",
          options: { presets: ["@babel/preset-react"] },
        },
      },
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"],
      },
    ],
  },
  resolve: {
    alias: {
      "@shared": path.resolve(__dirname, "../shared-lib/src"),
    },
    extensions: [".js", ".jsx"],
  },
  plugins: [
    new ModuleFederationPlugin({
      name: "mfe1",
      filename: "remoteEntry.js",
      exposes: {
        "./Test": "./src/Test.jsx",
      },
      shared: {
        react: { singleton: true },
        "react-dom": { singleton: true },
        "react-router-dom": { singleton: true },
      },
    }),
    new HtmlWebpackPlugin({
      template: "./public/index.html",
    }),
  ],
};

Enter fullscreen mode Exit fullscreen mode

What this does (quickly):

  • name & filename: Identifies the Remote and emits remoteEntry.js for the Shell to load.
  • exposes: Makes your module (e.g., ./src/entry.routes.jsx) importable as mfe1/Routes.
  • shared: Ensures a single copy of React/ReactDOM/Router across apps.
  • publicPath: Points to where the Remote serves assets at runtime.

Step 4: Bootstrap Your App for Module Federation

Just like the shell, your remote app also needs a clean way to handle startup logic. By separating the rendering process into a bootstrap.js file, we make sure that Module Federation can load and mount the app properly without conflicts.

  • Create a bootstrap.js file inside src/
// src/bootstrap.js
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

reportWebVitals();

Enter fullscreen mode Exit fullscreen mode

  • Update index.js
// src/index.js
import('./bootstrap');

Enter fullscreen mode Exit fullscreen mode

Step 5: Clean Up index.html and App.js

Before we move on, let’s tidy up the default files that come with Create React App in the Remote App. Cleaning up unnecessary code will help us focus only on the essentials.

  • Optimize public/index.html: Remove the default comments and metadata. Here’s a simplified version tailored for the Remote App.
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="description" content="Micro Frontend Remote App" />
    <title>Remote App</title>
  </head>
  <body>
    <div id="root"></div>
  </body>
</html>

Enter fullscreen mode Exit fullscreen mode

  • Simplify App.js: Now, update App.js to make it simple and clear.
import React from "react";

function App() {
  return (
    <div>
      <h1>Welcome to the Remote App</h1>
    </div>
  );
}

export default App;

Enter fullscreen mode Exit fullscreen mode

Step 6: Create a Test Component to Expose

Now, let’s create a simple component inside the Remote App that we’ll later expose to the Shell App.

Create a new file src/Test.jsx and add the following code:

import React from "react";

export default function Test() {
  return (
    <>
      <h1>Test from Remote App</h1>
    </>
  );
}

Enter fullscreen mode Exit fullscreen mode

Step 7: Run the Remote App

With everything set up, it’s time to run the Remote App and make sure it works properly.

npm start

Enter fullscreen mode Exit fullscreen mode

By default, the Remote App will run on http://localhost:3001
. You should see the welcome message when the app loads in the browser.

Here's a quick preview of what it looks like in the browser:

Screenshot of React Micro Frontend Remote App running on http://localhost:3001 displaying

✅ Great job! You’ve successfully built and configured your first Remote App for Micro Frontends using Module Federation.

This is just the beginning — in the next steps, you’ll connect this Remote App to the Shell and actually consume the exposed Test component.

Keep going. The exciting part starts now! 🚀