Menu

1 / 2

What happens when a Next.js micro-frontend needs a newer dependency?

DEV Community: nextjs·Tariq Khan·about 6 hours ago
#rFjvv7um
#devtonextjs#devto#dev#cart#remote
Long article (358 words) — no AI summary yet.
Reading 0:00
15s threshold

Tariq Khan

Posted on Dec 6

Edited on Dec 6

AI-assisted

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' } , } ,

Enter fullscreen mode

Exit fullscreen mode

The example host registers 1.0.0 . It passes the actual module along with that version.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.