Streaming SSR React Query Data
I've got a slow ensureQueryData call that I would like to defer/stream to the client upon completion. The data is used in a Suspense-wrapped component on my page via. useSuspenseQuery. The data however gets redundantly fetched again on the client side (even w/ a query client stale time set to 60 seconds) b/c the query data streamed to the client does not get hydrated - only the HTML of the Suspense-wrapped component gets streamed to the client.
Are there any kinda efforts to implement something like react-query-next-experimental for TanStack Router? Such that not only HTML within suspense boundaries get hydrated, but query data as well?
6 Replies
complex-teal•2y ago
I don't think so. What the plugin uses is nextjs specific unfortunately
national-goldOP•2y ago
Is the only dependency useServerInsertedHTML?
national-goldOP•2y ago
I'm curious if router.injectHtml could be used for this purpose

national-goldOP•2y ago
Looks like the behaviors are different.. router.injectHtml gets called immediately on invocation unlike useServerInsertedHTML
complex-teal•2y ago
Yeah it's only that hook. We're waiting on something from react to do that
national-goldOP•2y ago
There any issue you could link to that tracks it on the React repo?