Open hex2f opened 9 months ago
Example: if we have a
For now, I came up with a workaround where I immediately cancel rendering after starting. This seems to work okay but it's definitely not ideal. Need to look into how other frameworks accomplish this 🤔 Perhaps start by rendering the RSC, then render it to HTML?
hey, i made this RSC framework thing, i might be able to help with something :)
one question - you mention "frames" in a bunch of places, wdym by that?
also:
[...] which is then re-hydrated by fetching RSC from the __marz endpoint.
AFAIK: ideally you wouldn't need a second request to do hydrate. the usual strategy for this (in both Next and MFNG, which i've copied for Tangle) is to inject the chunks of the RSC payload into the SSR stream, generally via inline <script>
tags, then collect those into a ReadableStream on the client and do createFromReadableStream
off of that. this gives you an element you can pass to ReactDOM.hydrate
. it's a bit tricky but it lets you do it all in one request while maintaining streaming.
Currently the framework implements streaming SSR which is then re-hydrated by fetching RSC from the __marz endpoint. I think ideally that I'd want to skip streaming SSR and instead render a single "frame" on the server, so the client still gets a server rendered HTML frame that is then hydrated by RSC. Not sure on this though, so if anyone else has any better suggestions please share in this thread!