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.…