pbesh
pbesh3y ago

Recommended way to prefetch client-side

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?
2 Replies
sachin
sachin3y ago
See https://trpc.io/docs/v10/invalidateQueries for the react query utils pattern Our docs on this aren't great right now though
pbesh
pbeshOP3y ago
ahhhhh gotcha! I did see useContext kinda worked but couldn't find docs on it. thank you!

Did you find this page helpful?