What happens when a Next.js micro-frontend needs a newer dependency?
The cart team ships on Tuesday. The storefront team upgrades its cart package on Thursday. What...
The cart team ships on Tuesday. The storefront team upgrades its cart package on Thursday. What happens if Tuesday’s button already needs Thursday’s code?
I built next-federation so a Next.js host can load a separately deployed React component at runtime. In the demo, the remote Add to cart button changes the count in the storefront header. Both are reading the same cart context. That shared context is where version compatibility matters. App Router demo · Pages Router demo

Give the remote a version requirement
The example remote lists example-cart-context in shared. Replace that setting in examples/components-remote/vite.config.ts with this:
shared: {
'example-cart-context': { requiredVersion: '^1.0.0' },
},
The example host registers 1.0.0. It passes the actual module along with that version. The range accepts compatible stable 1.x releases, so the teams can update the host package independently. If the remote genuinely needs 1.0.0 exactly, use requiredVersion: '1.0.0'. If it starts using an API added in 1.4.0, set the minimum accordingly with ^1.4.0.
Make the mismatch visible
- Start the repository examples and click Add A1 to cart. Check that the header count changes.
- Stop the examples, change the range above to
^2.0.0, then restart them. The example runner builds the components remote again. Leave the host’s registered version at1.0.0. - Reload the storefront. The host should report
NF-036and show the cart button’s configured error fallback. - Restore
^1.0.0, restart, and verify that the header count updates again.
Run the examples · Shared modules guide
For a date formatter, bundling a private copy with fallback: true might be fine. For cart context, I want the button and header using the same store, so I keep it host-provided.
Before a remote depends on a newer share, I’d check which hosts already provide it and what the others will show. If you try this and the warning leaves you guessing which dependency to fix, I’d like to see the smallest repro. If the project helps you, a star is welcome. GitHub repository
Sumber artikel open-source oleh Tariq Khan di DEV Community — Baca artikel asli. Topik:
#nextjs#react#webdev#typescript
Sukai & bagikan artikel ini
Ditulis & Dikurasi Oleh
Tariq Khan (Open-Source)
Software Engineer yang berfokus pada Next.js, TypeScript, arsitektur backend skalabel, Cloud, dan Applied AI.
Artikel Terkait
Semua artikelBeyond the Browser: Engineering an Anime-Inspired Web Experience (Part 1/4)
Who decided software engineering portfolios had to consist of a navigation bar, a few project cards,...
The booking was saved, but the customer saw an error: email after commit in Next.js
This bug made it into the released versions of my Next.js 15 templates (two booking sites, a...
A remote just redeployed. What should the App Router hydrate?
A customer opens workspace settings on a slow connection. Next.js renders the usage panel from build...
Module Federation in Next.js 16 after nextjs-mf
Say your storefront has a product page in app/ and an older page in pages/. The cart team wants to...

Komentar