T
TanStack•16mo ago
genetic-orange

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

I beleive i did everything correctly form tanstack documentation
No description
5 Replies
genetic-orange
genetic-orangeOP•16mo ago
No description
genetic-orange
genetic-orangeOP•16mo ago
No description
genetic-orange
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 client
adverse-sapphire
adverse-sapphire•16mo ago
it should work just as well with useQuery
genetic-orange
genetic-orangeOP•16mo ago
So hard to figure out it was that 😅 skill issues i guess

Did you find this page helpful?