module-federation-examples
module-federation-examples copied to clipboard
Is there no more correct solution for next.js with ssr?
Is there no hack-free solution https://github.com/module-federation/module-federation-examples/blob/master/nextjs-ssr/host/next.config.js
remoteLib: isServer
? "remoteLib@http://localhost:3002/node/remoteEntry.js"
: //This is a hack (I cannot run successfully MF in client-side with NextJS and React, maybe doing smth wrong)
{
external: `external new Promise((r, j) => {
window['remoteLib'].init({
react: {
"${packageJsonDeps.react}": {
get: () => Promise.resolve().then(() => () => globalThis.React),
}
}
});
r({
get: (request) => window['remoteLib'].get(request),
init: (args) => {}
});
})`,
},
// : "remoteLib@http://localhost:3001/remoteEntry.js",
},```
bump
Yes there is but it's not open source and requires a paid workshop.
Take a look at this issue https://github.com/telenko/node-mf-example/issues/2
https://scriptedalchemy.medium.com/next-js-11-module-federation-and-ssr-a-whole-new-world-6da7641a25b4
For the SSR variant, there is only a paid workshop and no code examples.
Correct. You can use the code streaming plugin mentioned in this issue. But the fetch() system is pay to play. The source is only available to those who go to the workshop.
It was hard to solve, took us months
Close to releasing SSR support as a plugin for next. Already in production and should go into open beta soon
PR open for SSR support, however the plugin powering it is a closed beta for the time being while it undergoes testing.
https://github.com/module-federation/module-federation-examples/pull/1468
@ScriptedAlchemy Will there public version?
Unlikely. Too expensive to build and support for free unfortunately
plugin has been released: https://app.privjs.com/buy/packageDetail?pkg=@module-federation/nextjs-ssr
Is there a trial that I can try or any live version to see if it is working?
Email/DM me and that can be arranged.
https://next-federation-reference-architecture-checkout.vercel.app/ https://next-federation-reference-architecture-home.vercel.app/ https://next-federation-reference-architecture-shop.vercel.app/
@ScriptedAlchemy , the three demo sites above seem to be broken.
Yeah the core code has changed quite a bit and I’ve been focusing on internal app upgrades. im refreshing the implementation now to bring everything back up. It’s several releases behind right now, but I’ve got it up locally again so likely just need to redeploy the apps with the new plugin code
module-federation/node module-federation/nextjs-mf