Update next-auth session object in response to user's patch request update
P粉748218846
2023-08-26 10:02:00
<p>I searched the Internet for a long time but didn't find the answer. There are some ways to fix this, but they didn't work for me when I tried them.
So, when a user logs in and a session is created, how do I update the new data in that session object after the user is updated via a patch request on the API backend.
Thank you all for your replies and time. </p>
<p>I tried various "tricks" I found online, and they worked for some people, but not for me.
I want the session object to be updated after patch is called and user data is updated. </p>
So I wrote an article on Medium about how to fix this problem: How to use useSession() Hook to update user session data in NextAuth