T
tRPC

❓-help

Recommended way to prefetch client-side

Ppbesh9/23/2022
In react-query, you can do
queryClient.prefetchQuery(['todos', input], queryFn)
queryClient.prefetchQuery(['todos', input], queryFn)
In trpc, I seem to only have access to the useQuery option on my endpoints:
trpc.todos.useQuery(input)
trpc.todos.useQuery(input)
Is there a way to do trpc.todos.prefetchQuery(input) or similar?
Ssachin9/23/2022
See https://trpc.io/docs/v10/invalidateQueries for the react query utils pattern Our docs on this aren't great right now though
Ppbesh9/23/2022
ahhhhh gotcha! I did see useContext kinda worked but couldn't find docs on it. thank you!

Looking for more? Join the community!