queryClient.prefetchQuery not prefeching on the server (Next App Router)
I beleive i did everything correctly form tanstack documentation

5 Replies
genetic-orangeOP•16mo ago

genetic-orangeOP•16mo ago

genetic-orangeOP•16mo 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 clientadverse-sapphire•16mo ago
it should work just as well with
useQuery
genetic-orangeOP•16mo ago
So hard to figure out it was that 😅 skill issues i guess