Next.js Discord

Discord Forum

Issue in updating next-auth session data

Answered
Crazy ant posted this in #help-forum
Open in Discord
Crazy antOP
I am using getServerSession in server component and useSession in client component to fetch data from session.
How to update next-auth session data when database is updated.
When database is updated, I need to login again to reflect the updated data. my backend code is separate, I am making a post request using fetch to an api end point and I could update database successfully. But updated data does not reflect to my current session I need to logout and login for that. Please help.
Answered by B33fb0n3
You can update your session only clientside like this: https://next-auth.js.org/getting-started/client#updating-the-session

Keep in mind to validate the new object on server before saving.
View full answer

3 Replies