Can I use RSC (react-server-components) with Astro?
I need to use some React-specific API and I must do it from the server, meaning I have to use RSC (react-server-components) for rendering my components, but I also wanna have the advantages of Astro over other react-dedicated frameworks like NextJS or TanStack-Start (which doesn't support RSC yet).
So I was wondering if Astro supports RSC or if it's in the works and maybe even available in beta or alpha versions?
Deeper dive into my needs:
- If you have a better idea on how to make it work in Astro I'm open to it
- I'm dynamically importing and dynamically rendering React components out of a set of predefined react components
- The rules of what components to render come from an external CMS, that CMS has its own React context and I must wrap the hydrated client with that context so the client functionalities of these components will work
- The issue starts with the fact that in order for the context to be shared with other components it all must be hydrated under the same react-tree, meaning under the same client-island directive
- Due to the above requirements (same client island for all React components + required to dynamically import & render these React components on the server) I must use RSC for rendering the components and apply the client directive on that root RSC component so all of react will have a single island isolate, which is where I'm having issues, the docs don't mention RSC at all so I'm not sure of the RSC status on Astro
- BTW I know what I describe above is what NextJS does out of the box with RSC, which is why all the above logic works flawlessly on NextJS, I just have some other limitations with NextJS that Astro solves them for me so I'm migrating to Astro.