T
tRPC

trpc auto refreshes page when I lose focus

trpc auto refreshes page when I lose focus

Rrustclan4/17/2023
Hi, i thought this was a development environment only configuration, but it does it even in production. How am I able to change this functionality?
Nnlucas4/17/2023
It's a react query setting, can be changed globally in the QueryClient Worth exploring the docs for that, it's 1 key, but there are several in the same vein https://tanstack.com/query/v4/docs/react/reference/QueryClient#:~:text=%7D-,Options,-The%20options%20for%20fetchQuery
Rrustclan4/17/2023
Hi. Thank you 🙂 I have found refetchOnWindowFocus which is what I am looking for. Here is my fix for any future people.
export const api = createTRPCNext<AppRouter>({
config() {
return {
transformer: superjson,
queryClientConfig: {
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
},
},
},
export const api = createTRPCNext<AppRouter>({
config() {
return {
transformer: superjson,
queryClientConfig: {
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
},
},
},
https://tanstack.com/query/v4/docs/react/guides/window-focus-refetching

Looking for more? Join the community!

T
tRPC

trpc auto refreshes page when I lose focus

Join Server