Render multiple Remix apps simultaneously #9156
Replies: 3 comments 1 reply
-
Hey @estevaolucas. We are facing the same challenge (thinking about working with Remix SPA mode in a single-spa MFE architecture). Have you had any luck with your issues? |
Beta Was this translation helpful? Give feedback.
-
We're endeavoring to accomplish the same using a Microfrontend architecture based on NGINX SSI to assemble the final HTML page. It would be great if we could utilize multiple Remix-based apps to develop the individual pieces that NGINX will stitch together. However, we faced the same issues with globals/window, so we're currently developing the single pieces implementing the SSR/data fetching manually, without leveraging on Remix. My understanding is that FoW will still rely on a global |
Beta Was this translation helpful? Give feedback.
-
We further a proof of concept using Remix with both rendering more than one Remix app on a single page via a proxy server that merged the SSR output, and a proof of concept of Remix as a single-spa application, and had to make a handful of changes to make these compatible. In both of these, the Multiple Remix apps on a single page The window global variables needed to be scoped, as suggested in this thread. Specifically, Remix in local dev relies on: Remix app as a single-spa application The global variables in this architecture can be removed off the window scope on unmount and restored on application mount so that multiple Remix applications can work independently as long as only one Remix application is mounted at a time. However, we found the challenge here to be in mounting applications a second time. The issue here was primarily caused by module-level variables retaining state across multiple application mounts. In particular, we had to reset this remix/packages/remix-react/components.tsx Line 693 in ede2012 Our findings so far suggest that for Remix to work well in a multi-Remix app environment, both the global window variables as well as the re-mountability (i.e. the ability to destroy an app and re-mount it) of Remix would need to be improved. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello Remix team,
In our journey towards adopting a micro-frontend architecture through single-spa and React, we've made significant strides and successes using React Router. With the recent introduction of Spa Mode, our interest peaked in leveraging Remix's capabilities to enhance our apps further.
One of our latest explorations involves integrating Remix into our micro-frontend ecosystem. I've successfully created an MFE using Remix, bypassing the need for single-spa + SystemJS format, which is :chefkiss:. Our implementation allows assets to be served correctly from the MFE's domain by prefixing a base URL in the HTML generated by
entry.server
. Workaround, thus it'd be great if we could prefix assets via Vite'sbase
and also be able to support SSR'sloader
(loader
's request will be made from callee/host's domain and not MFE's one. But these are considerations for another discussion.Our current challenge lies in the limitation of not being able to render multiple Remix applications simultaneously within the same DOM/window. For instance, consider a scenario in our non-React application that mounts a Remix MFE from Team A, and upon user interaction, a modal hosted in another Remix MFE by Team B is supposed to show up. The utilization of global/window variables by Remix, such as
__remixContext
,__remixManifest
, and the__hmr
variable in development mode, hinders the simultaneous rendering of multiple Remix apps due to global variable collisions.This brings us to a couple of questions for the Remix team:
window.myAppNameFromViteConfig.__remixContext
) be a viable solution?The ability to seamlessly integrate multiple Remix-based micro-frontends would significantly bolster our architecture and development workflow. If Remix is open to this idea, I am eager to contribute towards making it a reality, especially with some initial guidance on the expected implementation approach.
Please let me know if you guys need more info.
Looking forward to your insights and suggestions.
Beta Was this translation helpful? Give feedback.
All reactions