core icon indicating copy to clipboard operation
core copied to clipboard

Migration offramp examples for nextjs

Open MaykonMorais opened this issue 1 year ago • 9 comments

Clear and concise description of the problem

With the change of next-mf status to maintenance, we noticed that it might be necessary to create examples for teams already considering migrating to other frameworks. I imagine that teams will make this transition gradually, so it would be helpful to consider a way for Next.js to interoperate with other frameworks, facilitating this change.

The examples could be organized by some recommended frameworks. Here are a few ideas:

  • Next.js (host) with Rsbuild/Rspack (remote)
  • Next.js (host) with ModernJS (remote)
  • Next.js (host) with Remix (remote) ... Feel free to add more recommendations.

I believe these examples will be very helpful for those already thinking about migrating and will be of great value to the community.

Suggested solution

  • Build a few of examples with different frameworks mentioned above that interop with Nextjs and post on MF Examples repo
  • Build a section with migration guide on Docs.

Alternative

No response

Additional context

No response

Validations

  • [X] Read the Contributing Guidelines.
  • [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

MaykonMorais avatar Nov 06 '24 15:11 MaykonMorais

I think we will have to reverse the strategy.

Next.js (remote) with Rsbuild/Rspack (host) Next.js (remote) with ModernJS (host) Next.js (remote) with Remix (host)

Youd take your current host, make it a remote, and use a new host who actually works well to pull the legacy next app back into it.

Next hosts are almost impossible to accept non next remotes.

We would have to create share replacements/shims for link,router, etc - nextjs is a locked system and will only work with its own stuff.

Any shim we create to try and reverse the order, Vercel will most likely try and break. We would need to disable Vercels ability to use make changes in effort to eat up our bandwidth with games of cat and mouse, the best way to lock them out of manipulating next.js deliberately to break federation offramps is to remove them as host and put a non-adversarial host in place.

Next.js is largely weaponized against federation, we have to assume its owner is hostile and act accordingly.

ScriptedAlchemy avatar Nov 09 '24 01:11 ScriptedAlchemy

I agree, this approach makes a lot of sense! Reversing the role of Next.js to act as a remote while using a host with better federation compatibility is a smart strategy, especially given the constraints of the Next ecosystem.

MaykonMorais avatar Nov 10 '24 15:11 MaykonMorais

Totally, ill work on something soon

ScriptedAlchemy avatar Nov 10 '24 20:11 ScriptedAlchemy

There are also some Tanstack examples in the works, with Tanstack Start coming along its a very interesting alternative as well.

zackarychapple avatar Nov 11 '24 16:11 zackarychapple

@zackarychapple do they work with SSR yet? I know vite base does not currently support ssr AFIK, are they rspack / webpack based?

ScriptedAlchemy avatar Nov 12 '24 02:11 ScriptedAlchemy

Stale issue message

github-actions[bot] avatar Jan 11 '25 15:01 github-actions[bot]

Bump

ScriptedAlchemy avatar Jan 13 '25 14:01 ScriptedAlchemy

Is it possible today to have a Next.js producer using next-mf be loaded into a non-next.js consumer that's using the rsbuild MF plugin or federation runtime if the Next.js remote module is not importing anything from next/*?

Curious if this use case is supported and how to do it.

amazrn avatar Feb 13 '25 16:02 amazrn

Yeah it should work

ScriptedAlchemy avatar Mar 15 '25 22:03 ScriptedAlchemy

@ScriptedAlchemy

RE: Tanstack Start

They are vite+vinxi+nitro-based. SSR is working. Does that mean it will work out-of-the-box or actualy not even close?

antitoxic avatar Apr 13 '25 17:04 antitoxic

@ScriptedAlchemy

RE: Tanstack Start

They are vite+vinxi+nitro-based. SSR is working. Does that mean it will work out-of-the-box or actualy not even close?

Jumping in here to chime in. I'm not sure if anyone has explicitly tried using Tanstack Start with Rolldown yet. Maybe @tannerlinsley or @yyx990803 will know, but with Vite + Rolldown you have built in module federation support that is native to the bundler and not via a community plugin. This "should", emphasis on the word should, work out of the box. @underfin shared an example here. If you do adapt it to work with tanstack start please let us know and open a PR to examples so we can add it.

zackarychapple avatar Apr 13 '25 22:04 zackarychapple

Stale issue message

github-actions[bot] avatar Jun 13 '25 15:06 github-actions[bot]