Chen
Chen11mo ago

Can you ensureData without the useUtils hook?

The Tanstack Router docs recommend calling ensureQueryData in a route’s loader function if using Tanstack Query: https://tanstack.com/router/v1/docs/guide/external-data-loading#a-more-realistic-example-using-tanstack-query As far as I can tell, ensureQueryData is only available through the trpc useUtils hook in a component. Can I get it, or the full query options, some other way?
External Data Loading | TanStack Router Docs
⚠️ This guide is geared towards external state management libraries and their integration with TanStack Router for data fetching, ssr, hydration/dehydration and streaming. If you haven't read the standard Data Loading guide To Store or to Coordinate?
Solution:
I had the same problem so in v11 there's createQueryUtils which allows you to do it without the hook
Jump to solution
3 Replies
Solution
SebasPtsch
SebasPtsch11mo ago
I had the same problem so in v11 there's createQueryUtils which allows you to do it without the hook
Chen
ChenOP11mo ago
Thanks - is it createTRPCQueryUtils?
SebasPtsch
SebasPtsch11mo ago
Yes