Replies: 1 comment
-
Hi @Najma099, Thanks for sharing your repo and detailed steps. This “login hangs after logout without page refresh” is a known tricky issue when using NextAuth with the Next.js App Router, especially with Server Actions. What’s likely happening?
Possible solutions:
Add a redirect after signOut() completes, for example:
This forces a fresh page load and clears any stale auth state.
Call signOut like:
and let NextAuth handle the redirect.
If you’re using React Query, SWR, or other client cache layers, reset them after logout to avoid stale data.
Ensure your signOut() call inside the form action properly triggers client-side revalidation or state update.
This ecosystem is rapidly evolving, and some edge cases with the App Router and Server Actions are still being ironed out. Hope one of these helps fix the hanging login after logout without refresh. Let me know if you want help debugging or adjusting your code. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Github link - https://github.com/Najma099/next-auth
I'm facing a strange issue in my Next.js App Router project using NextAuth (v5, credentials provider) and would appreciate any help or insights!
Problem Flow
I load the website for the first time (unauthenticated) — it correctly shows the login page.
I enter my credentials — everything works fine, I'm redirected to /settings.
I click logout — it correctly redirects me to the login page.
But now, if I try to log in again immediately, the login request hangs.
The query string (?callbackUrl=...) updates.
But nothing happens — no redirect, no error — the page is stuck.
If I manually refresh the page after logout, login works again normally.
Additional information
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions