Skip to content
Discussion options

You must be logged in to vote

as pointed out on twitter, I think we should change the example to use two different methods of data fetching for server and client, similar to what swr does: https://swr.vercel.app/docs/with-nextjs#pre-rendering-with-default-data

maybe something like:

 // pages/posts.jsx
 import { QueryClient, useQuery } from 'react-query'
 import { dehydrate } from 'react-query/hydration'
 
 export async function getStaticProps() {
   const queryClient = new QueryClient()
 
   await queryClient.prefetchQuery('posts', getPostsFromDatabase)
 
   return {
     props: {
       dehydratedState: dehydrate(queryClient),
     },
   }
 }
 
 function Posts() {
   // This useQuery could just as well happen in some…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dcorb
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