rustclan
rustclan15mo ago

trpc auto refreshes page when I lose focus

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?
3 Replies
Nick
Nick15mo ago
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
rustclan
rustclan15mo ago
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