Hackforge Academy

Category: react

What Are Shared Dependencies?

Published on 22 Aug 2026

Explanation

Shared dependencies are libraries that multiple Micro Frontends use. Instead of loading separate copies, Module Federation can share libraries such as React and React DOM between the Host and Remote applications.

Code:

Host App
   │
   ├── React
   └── React DOM

Remote App
   │
   ├── React ──→ Shared
   └── React DOM ──→ Shared

Explanation

Sharing dependencies can reduce duplicated JavaScript, improve application performance, and help ensure that the Host and Remote use compatible versions of important libraries.

Code:

Without Sharing:
Host → React
Remote → React

With Sharing:
Host ──┐
       ├── Shared React
Remote ─┘

Explanation

The singleton option ensures that only one instance of a dependency is used across the federated application. This is especially important for React because multiple React instances can cause problems with shared state and hooks.

Code:

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

Explanation

Module Federation can define required versions for shared dependencies. This helps prevent incompatible versions from being used between the Host and Remote applications.

Code:

shared: {
  react: {
    singleton: true,
    requiredVersion: '^18.0.0'
  }
}

Explanation

In a Micro Frontend architecture, commonly used libraries can be shared while each Remote continues to manage its own business-specific dependencies.

Code:

                  Host
                   │
        ┌──────────┴──────────┐
        ↓                     ↓
   Product Remote         Cart Remote
        │                     │
        └──────────┬──────────┘
                   ↓
          Shared Dependencies
          ├── React
          └── React DOM

🚀 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