How to update session

https://next-auth.js.org/getting-started/client#updating-the-session Similar to nextAuth, is there a way to trigger the session update?
Client API | NextAuth.js
The NextAuth.js client library makes it easy to interact with sessions from React applications.
7 Replies
bekacru
bekacru2mo ago
const { refetch } = client.useSession();

refetch();
const { refetch } = client.useSession();

refetch();
varundeva
varundeva2mo ago
Will it update even if i use secondary db redis? Because i was created one thread related to this
arpitBhalla
arpitBhallaOP2mo ago
Hi, thanks for responding, NextAuth supports following, unlike refetch, this way we can update the session directly
update({ name: "John Doe" })
update({ name: "John Doe" })
bekacru
bekacru2mo ago
you can use authClient.updateUser yes
varundeva
varundeva2mo ago
Then this will work i guess I'm updating additional fields in user table. And previously i was able to get updated value in session only after logout and login Need to try this
arpitBhalla
arpitBhallaOP2mo ago
What are you building?
varundeva
varundeva2mo ago
I'm just building application which is having onboarding form There dob, address few fields are there Once user saved that i need it back with updated data I added additional fields in user table

Did you find this page helpful?