Why Next-auth Session Not Containing the user data(like email, name etc) after Login #11272
-
#Here is my Code import ConnectToDb from "@/Lib/ConnectToDb"; interface AuthProps { export const authOptions: NextAuthOptions = {
}; const handler = NextAuth(authOptions); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Firstly, I am not sure why I am encountering this error. I did everything correctly. However, when I looked closely, I realized that you need to specifically return the data like this:
|
Beta Was this translation helpful? Give feedback.
Firstly, I am not sure why I am encountering this error. I did everything correctly. However, when I looked closely, I realized that you need to specifically return the data like this:
return { id: user._id.toString(), name: user.name, email: user.email };
This worked for me.