How to disable refetch on windows focus
Unanswered
Persian posted this in #help-forum
PersianOP
My web application automatically refresh the data when the page is focused or navigated to another page..
How can i disable that and make that data only refresh once user refresh the page
How can i disable that and make that data only refresh once user refresh the page
24 Replies
PersianOP
Ping when reply
PersianOP
.....
Original message was deleted
PersianOP
when i navigate to another page the page automatically refresh the data on it by fetching new data
this includes next-auth and the data i get from ssr with mongodb
i want a way to stop this and make the data only be called on refresh
this includes next-auth and the data i get from ssr with mongodb
i want a way to stop this and make the data only be called on refresh
PersianOP
sorry, when i mean navigate to another page, i meant by that new tab**
@Persian when i navigate to another page the page automatically refresh the data on it by fetching new data
this includes next-auth and the data i get from ssr with mongodb
i want a way to stop this and make the data only be called on refresh
Maltese
Next auth has the option to disable refetch on window, if you mean this
@Maltese Next auth has the option to disable refetch on window, if you mean this
PersianOP
can you send docs for it?
its called
refetchOnWindowFocus@Clown its called `refetchOnWindowFocus`
PersianOP
I made it false but it's still refetching when i switch between tabs
close the open tabs and restart the server maybe
if it still doesnt work idk
@Clown close the open tabs and restart the server maybe
PersianOP
still ):
is it happening on every refocus
or is it just happening after a fix interval?
PersianOP
when i switch the tabs yes
import "./globals.css"
import { SessionProvider } from "@components/providers/SessionProvider";
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<SessionProvider
refetchInterval={5 * 60}
refetchOnWindowFocus={false}
>
{children}
</SessionProvider>
);
}try zeroing out refetch interval too
@Clown try zeroing out refetch interval too
PersianOP
What's that sorry?
refetchIntervalMaltese
I am pretty sure there is a solution for this, but I recommend don’t removing it because its purpose is if you have two tabs with the same app if you log out in one of them, then you will automatically log out in the second
PersianOP
okay i will not..
Maltese
I know the next-auth docs are a little hard to follow, but if you talk to chat gpt, experimenting and writing notes you will get all about it
Chinese Alligator
I prefer not disable it to maintain tabs sync. Check your auth Config and set in session prop maxAge param