How to disable refetch on windows focus
Unanswered
American Shorthair posted this in #help-forum
American ShorthairOP
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
American ShorthairOP
Ping when reply
American ShorthairOP
.....
Original message was deleted
American ShorthairOP
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
American ShorthairOP
sorry, when i mean navigate to another page, i meant by that new tab**
@American Shorthair 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
American ShorthairOP
can you send docs for it?
its called
refetchOnWindowFocus@Clown its called `refetchOnWindowFocus`
American ShorthairOP
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
American ShorthairOP
still ):
is it happening on every refocus
or is it just happening after a fix interval?
American ShorthairOP
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
American ShorthairOP
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
American ShorthairOP
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