Skip to content
Discussion options

You must be logged in to vote

I only set the initialData if the page is 1, if it's not, then nothing is set. This works just fine, the first page is loaded up with the data from getServerSideProps, and the next pages are loaded from scratch, without any initialData set. But is this a bad thing?

that's totally legit. The only more generic solution would be to use hydration: https://react-query.tanstack.com/guides/ssr#using-hydration

with that, you would use await queryClient.prefetchQuery(['list', 1], () => fetch(/*content from page 1*/)) and then send the whole dehydrated QueryClient to the frontend, where you would hydrate it. Once you get around to your useQuery where you want data for the first page, you should i…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by mauriciosoares
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants