next-auth
next-auth copied to clipboard
signOut function from auth.ts export doesn't reload the client side useSession state
Environment
System:
OS: Windows 11 10.0.22631
CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
Memory: 5.41 GB / 15.87 GB
Binaries:
Node: 20.11.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
pnpm: 9.0.6 - C:\Program Files\nodejs\pnpm.CMD
Browsers:
Edge: Chromium (125.0.2535.92)
Internet Explorer: 11.0.22621.3527
npmPackages:
next: 14.2.3 => 14.2.3
next-auth: 5.0.0-beta.19 => 5.0.0-beta.19
react: ^18 => 18.3.1
Reproduction URL
https://github.com/Senbonzakura1234/debug-signout-nextauth
Describe the issue
When i signout using the signOut function from auth.ts export, the app redirect to the callbackUrl as expect, but the session state in client does not update, it still displaying content that supposed to be authenicated view only. The content only disappear when i press F5 to fully reload the page.
The legacy signOut function export from next-auth/react still works as expected though
How to reproduce
- signin the app
- press btn
Go to Sign In Pageto redirect tosignOutpage - perform signOut by press btn
Confirm Sign outand app will redirect to the callBackUrl
Expected behavior
- the
useSessionstate have to returnunauthenticated
I'm currently using
window.location.reload(); in the event handler function as a workaround.
I'm currently using
window.location.reload();in the event handler function as a workaround.
@erikash what was the behavior of the legacy signOut func, did they also use window location? How did they clear the local session state?
any update on this issue?
Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!