Hackforge Academy

Category: react

Shared Components

Published on 22 Aug 2026

Explanation

Micro Frontends can share reusable UI components such as buttons, forms, modals, and navigation elements. This helps maintain a consistent user experience across independently developed applications.

Code:

Shared UI Library
├── Button
├── Input
├── Modal
└── Card

Product App → Button
Cart App    → Button
Payment App → Button

Explanation

With Module Federation, one Remote application can expose a component so that other Micro Frontends can consume it without duplicating the component's source code.

Code:

exposes: {
  './Button': './src/components/Button.jsx'
}

Explanation

A Host or another Remote can import the exposed component and use it like a normal React component.

Code:

import Button from 'uiApp/Button';

function Product() {
  return <Button>Buy Now</Button>;
}

Explanation

Common libraries such as React and React DOM can be shared between Micro Frontends to avoid loading multiple copies and to maintain compatibility.

Code:

shared: {
  react: { singleton: true },
  'react-dom': { singleton: true }
}

Explanation

A scalable Micro Frontend architecture can use a dedicated UI library or Remote to provide common components while individual Micro Frontends continue to own their business-specific components.

Code:

                    Host
                      │
          ┌───────────┼───────────┐
          ↓           ↓           ↓
      Product       Cart       Payment
          │           │           │
          └───────────┼───────────┘
                      ↓
               Shared UI Library
               ├── Button
               ├── Input
               └── Modal

🚀 Learn Spring Boot with real-world projects

💡 Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
⚛️

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community