TkDodo
Read post

TanStack Router and Query

TanStack Router has a built-in per-route cache, but TanStack Query's global QueryCache is better suited for data shared across multiple routes. The post explains why using route loaders to prefetch queries (without awaiting) is a best practice, how to wire up the queryClient in router context, and why components should use useQuery or useSuspenseQuery instead of useLoaderData. It also covers disabling the router's own caching when Query is in charge, the decision between blocking and deferred data loading, and how the integration extends to TanStack Start with SSR streaming that seeds the client-side QueryCache automatically.

    #react
May 26•9m read time•From tkdodo.eu
Post cover image
Table of contents
Combining Query and RouterAdd the QueryClient to the Router ContextuseQuery or useSuspenseQuery ?To await or not to await in the loaderAlways use a QueryTreat the loader as an event handlerContinue Series
140.7K Impressions3 Comments
TkDodo's image
TkDodo

TK Dodo is a platform dedicated to sharing insights and resources on software development, technolog...

184 Followers

•

1.4K Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard