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

推荐订阅源

V
V2EX
小众软件
小众软件
GbyAI
GbyAI
B
Blog RSS Feed
月光博客
月光博客
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
Blog — PlanetScale
Blog — PlanetScale
U
Unit 42
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Vercel News
Vercel News
F
Fortinet All Blogs
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
雷峰网
雷峰网
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
Engineering at Meta
Engineering at Meta
aimingoo的专栏
aimingoo的专栏
博客园_首页
G
Google Developers Blog

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
Shared Redux Store in Next.js Module Federation: Cross-Re...
Srinu Web de · 2026-05-01 · via DEV Community

Srinu Web developer

// Auth React remote dispatches:
dispatch(setIsLoggedIn({ isLoggedIn: true }))

// Products Next.js remote reads:
const isLoggedIn = useAppSelector(selectIsLoggedIn)
// → returns FALSE

Enter fullscreen mode Exit fullscreen mode

You log in. Cart still says you didn't.

If you've built a hybrid micro frontend with React remotes (ModuleFederationPlugin) loaded inside a Next.js host (NextFederationPlugin), you have either hit this bug or you will. Open Redux DevTools and you'll see two store instances — one created by the Auth remote, one created by Products. Each remote dispatched into its own copy.

The contract that fixes it

A federated Redux singleton. One @myapp/store package. The host imports it once, creates the store, wraps the app in `. Every remote importsuseSelectoranduseDispatch` from that same package, and Module Federation guarantees they all receive the host's instance — not a fresh one.

What the article covers

  • Complete @myapp/store package codeconfigureStore, slices, re-exported react-redux primitives
  • ClientReduxProvider + ssr: false — why importing the store at the top of _app.tsx crashes the server build
  • The shared block in host next.config.js and every remote (webpack.config.js for React, next.config.js for Next.js) — singleton + strictVersion contract
  • 5-step Module Federation runtime negotiation — register, dynamic import, version match, reuse
  • Real codebase examples — Auth (React) dispatching setIsLoggedIn, Products (Next.js) reading selectAccessToken
  • Why each remote keeps its own ClientReduxProvider — for standalone dev only
  • SSR + federated Redux hydration trap — skip SSR for federated state, hydrate on client mount
  • 7 gotchas that account for almost every "state is not propagating" bug
  • State decision matrix — federated store vs local useState vs URL search params vs TanStack Query

The one debug step that solves 80% of these bugs

Open Redux DevTools. Count the stores. If there is more than one, the singleton negotiation has failed and your shared block has a typo or a missing singleton: true somewhere. Fix that first. Everything else is a waste of time until there is exactly one store in DevTools regardless of how many remotes are mounted.

Read the full guide with code examples → Shared Redux Store in Next.js Module Federation Guide