-
-
Notifications
You must be signed in to change notification settings - Fork 797
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
[legacy-framework] allow useQuery
to run during SSR or SSG
#1940
Conversation
b7c15ed
to
6c4b05e
Compare
Switched to reactRoot and would you look at that, a green checkmark! It's what I was hoping for, but you can never be sure what you're going to get 😁 |
Ok last thing @MrLeebo, do we need to update or add any docs? |
@flybayer Definitely. At minimum, the content at https://blitzjs.com/docs/pages#automatic-static-optimization will need to be updated, and there may be other broader repercussions I'm not even aware of yet. |
useQuery
to run during SSR or SSG
useQuery
to run during SSR or SSGuseQuery
to run during SSR or SSG
This allows useQuery to run on the server, iff there's precached data. We do this by calling useReactQuery with enabled:false and seeing if there's data returned. If there's no data, we throw a suspender to emulate the previous behavior.
To prefetch data, you can run something like this in getStaticProps
and then you can pass the resulting cache to the client with
So you get identical results on first render.