Start + useQuery prefetch question
Hi! I was under the impression that with
react-router-with-query
, we'd be able to start a query on the server and continue it on the client with useQuery
, even when the query doesn't fully resolve inside the loader - essentially continue the query where the server left off. I'm wondering if that is actually the case or if that is only possible with useSuspenseQuery
.
In the example below, without any nested components, our query takes two seconds to resolve. If we prefetch inside the loader (without awaiting the prefetch or any subsequent duration), we will get data (1) from useQuery - the query runs fully in the client. When the loader is longer and allows for the query to fully resolve in the server, we get data (2), fetched in the server.
useSuspenseQuery
will work and initially render the data (2), prefetched in the server, but will then immediately start refetching in the client when the component renders and replace it - which we tried to prevent unsuccessfuly with various combinations of route and queryClient staleTime.11 Replies
extended-salmonOP•3mo ago
evident-indigo•3mo ago
there is a sync issue still in the library. it will soon be resolved when we migrate to seroval serializer
dependent-tan•3mo ago
https://discord.com/channels/719702312431386674/1388905387083829438
Any chance this is related?
evident-indigo•3mo ago
don't think so. the sync issue affects promise streaming
especially for useSuspenseQuery
extended-salmonOP•3mo ago
Good to know, thanks for the fast reply! I suppose this affects both the useQuery and useSuspenseQuery approaches?
evident-indigo•3mo ago
no only useSuspenseQuery
if you do not await a query in the loader it won't be streamed right now
only if awaited or accessed via useSuspenseQuery
we might be able to stream non awaited queries in the future
extended-salmonOP•3mo ago
Yeah, this is what I was expecting - I think it'd be a great addition.
And I think this would be a good add to the docs as well
evident-indigo•3mo ago
we dont have docs about the query integration at all right now i guess 😄
so yes, this should all be properly documented
extended-salmonOP•2mo ago
Awesome, thanks for the input. Looking forward to these changes
@Manuel Schiller great job with the seroval integration, amazed by the shipping speed
ambitious-aqua•2mo ago
Could you share the MR?
extended-salmonOP•2mo ago
GitHub
feat: use seroval for SSR by schiller-manuel · Pull Request #4600 ...
also stream all queries in react-router-with-query