How to invalidate query in T3?
Hello, how can i invalidate query in TRPC like that?
When its query, but it does not have any queryKey, revalidate or something like that.. Im using T3 Stack with nextjs. Thanks!
7 Replies
you cant invalidate
query
because its not being cached anywhereheres how invalidation works in general https://trpc.io/docs/client/react/useUtils#query-invalidation
useUtils | tRPC
useUtils is a hook that gives you access to helpers that let you manage the cached data of the queries you execute via @trpc/react-query. These helpers are actually thin wrappers around @tanstack/react-query's queryClient methods. If you want more in-depth information about options and usage patterns for useUtils helpers than what we provide her...
I mean useQuery, wrong snippet, sorry:
i can use refetch on that
but i cannot pass any keys or something to useQuery?
did you read the page i linked
i've send snippet before i started reading. Now i saw that, thanks! as i can see i cannot force server TRPC request to refetch? Or ill just need to revalidate the route with nextjs?
yea in server components theres nothing to invalidate clientside
because youre sending Basically Html