P粉4818158972023-08-27 09:17:05
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
import { useSession } from 'next-auth/client'; export default function UserInfo() { const { data: session, update } = useSession(); const handleUpdateUser = async () => { const newSession = { ...session, user: { ...session?.user, email: "someone@example.com" }, }; await update(newSession); }; return ( <button onClick={handleUpdateUser}> 更新用户 </button> ); }