-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(react): add refetchOnWindowFocus option to SessionProvider #3730
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! 🙏 💚
@timakin could you please add this to the documentation under https://next-auth.js.org/getting-started/client#options as well? There is an edit button at the bottom, but here is the repo https://github.com/nextauthjs/docs |
Thank you for implementing this feature. I need this as well since we already have a refresh token flow in our app. Any idea when this can be published to NPM? |
@hboylan |
@timakin no, I will use the refresh token to fetch a new access token and retry the service request when my service responds with 401 unauthorized. Meaning the access token is expired. Therefore, I would like to use this new SessionProvider prop to prevent next-auth from fetching a new session and hitting the OAuth service unnecessarily This is exactly the feature I've been looking trying to reproduce. 😄 |
@hboylan |
@timakin Basically, I would like to set
|
@balazsorban44 Hi 👋 |
The original feature request (#3450) looks left behind for about a month.
But because you can't control whether to refetch session when you focus on a browser, some issues still occur (like form resetting, duplicated API calls, etc).
So I re-open this PR instead of @filipditrich (almost all of this feature depend on his effort) and handle @balazsorban44 's reviews.
Following descriptions are copies from here.
Adding new option refetchOnWindowFocus to SessionProvider component which disables session refetching in visibilitychange event callback.
Reasoning 💡
Automatic refetching on tab switching is usefull but it should be controllable by user, since it may be an expensive operation.
Checklist 🧢
TestsAffected issues 🎟
Fixes #3405