-
Notifications
You must be signed in to change notification settings - Fork 5
Description
We would like to use Suspense for Data Fetching in an SSG setup (Capri + React).
The idea is to use renderToPipeableStream()
+ onAllReady()
or
renderToReadableStream()
+ await stream.allReady
to get the final markup after all suspense boundaries have resolved.
This already works when using SWR 1.x, but SWR 2.x will no longer run on the server as it has no way of transferring the data to the client.
I understand that the way forward for SSR will be React Server Components, but this doesn't sound like a viable solution for generating static markup.
I could imagine that using a primitive like react-fetch would be a suitable option in the future, but currently react-dom/server
does not implement getCacheForType()
so this does not work (yet?).
I guess the question boils down to this: Will there be a supported way to use Suspense for Data Fetching in an SSG context, or will we need to fetch the data outside of React with a Next.js-style getStaticProps
pattern?