Dynamic route for other MFE's pages
The question I have is regarding SSR. I'm trying to implement my application as shown below. https://github.com/module-federation/module-federation-examples/tree/master/nextjs-ssr In these examples, we have imported the pages from other MFEs to create file-based routings. In all MFEs, this has been done. As shown below, I have tried to create a dynamic route for example [...slug].js in the home MFE
const SlugPage = dynamic(() => import("shop/shop"));
const Slug = SlugPage;
Slug.getInitialProps = async (ctx) => { const getInitialProps = (await SlugPage).default?.getInitialProps; if (getInitialProps) { return getInitialProps(ctx); } return {}; };;
export default Slug;
Would it be possible to use such a dynamic route to load other MFEs' pages, for example, when I access '/shop' it should load the index page of the shop, when I access '/checkout' it should load the index page of checkout, and similarly for other MFEs including nested routes like "/shop/products"?
Modernjs.dev/en will support this next quarter. Along with SSR support, TS support and HMR
Doing dynamic routes on next is very limited. Only get initial props would work. Modernjs has its router designed for federation.
Is there any reference related to Modern.js like how to achieve dynamic routing ?
In the next release it should be simply built on. "Just works" - there will be a new option like "discoverRoutes: true"