Next.js Discord

Discord Forum

Nextauth.js Issue with useSession Not Updating on Client Side

Unanswered
Mackenzie River Husky posted this in #help-forum
Open in Discord
Mackenzie River HuskyOP
Hi everyone!

I'm facing an issue where the data in useSession doesn't update on the client side. This becomes a problem because when a user logs in, the cart still shows the 'login to checkout' button. However, if I refresh the page, everything works perfectly.

Additionally, the session updates correctly with OAuth and logout, but the issue seems to occur only with credentials.

The login process works flawlessly on the server side, and the user data is retrieved immediately after logging in. I've attached images of my code, and I would really appreciate any help since I haven't been able to find anything useful online.
Version what i use: "next-auth": "^5.0.0-beta.20",

Thanks in advance!

5 Replies

Barbary Lion
Is the client session used in a Next layout by any change?
Mackenzie River HuskyOP
No, only the required SessionProvider from 'next-auth/react'.
Mackenzie River HuskyOP
any idea?
Lakeland Terrier
Maybe missing a revalidate for the correct path after the action?
Mackenzie River HuskyOP
Unfortunately, it's not just at Crediant where this update doesn't happen automatically, and even if I enter revalidatePath("/") within the cred or in the server action, it doesn't help either, unfortunately. Any other ideas on why it might not refresh only with the cred?