T
TanStack•2y ago
xenial-black

queryClient.prefetchQuery not prefeching on the server (Next App Router)

I beleive i did everything correctly form tanstack documentation
No description
5 Replies
xenial-black
xenial-blackOP•2y ago
No description
xenial-black
xenial-blackOP•2y ago
No description
xenial-black
xenial-blackOP•2y ago
But I don't get access to the data instantly on the client, i need to wait the fetch on the client and load Is there anything wrong in my implementation ? after 3h of debugging, i find out that it works as expected using useSuspenseQuery it wait on the server and when it renders i get the data instantly it seems like the useQuery as the documention uses it in the advanced hydration section is incorrect, it will not use the cached data from the server and the data will be undefined until the client fetch finishes Or i'm 100% wrong which is possible 😄 hmmm...never mind, even with useSuspenseQuery it sends a network request even with the stale time 😦 FIXED : I was using an RPC call on the server components which returns a JSON response already, so the serialization happens 2 times. Which is incorrect and does not match with client
spiritual-aqua
spiritual-aqua•2y ago
it should work just as well with useQuery
xenial-black
xenial-blackOP•2y ago
So hard to figure out it was that 😅 skill issues i guess

Did you find this page helpful?