tRPCttRPC
Powered by
ChenC
tRPC•3y ago•
4 replies
Chen

Can you ensureData without the useUtils hook?

The Tanstack Router docs recommend calling
ensureQueryData
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
ensureQueryData
is only available through the trpc
useUtils
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
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

can I use useUtils hook in trpc 11 ?
codecret | Software EngineerCcodecret | Software Engineer / ❓-help
8mo ago
Can you get the queryClient without using a hook?
PieterPPieter / ❓-help
3y ago
useUtils vs useQueryClient
RealityShiftRRealityShift / ❓-help
3y ago
Where did useUtils go?
JonathanJJonathan / ❓-help
12mo ago