Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[react] Suspense for Data Fetching + Static Site Generation? #39

Closed
fgnass opened this issue Jul 17, 2022 · 1 comment
Closed

[react] Suspense for Data Fetching + Static Site Generation? #39

fgnass opened this issue Jul 17, 2022 · 1 comment

Comments

@fgnass
Copy link
Contributor

fgnass commented Jul 17, 2022

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/serverdoes 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?

@fgnass
Copy link
Contributor Author

fgnass commented Jan 22, 2023

I'm closing this for now, as the Capri react template now uses the data loading infrastructure provided by react-router v6. The same can be achieved with TanStack Router.

@fgnass fgnass closed this as completed Jan 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant