DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

T-Kisaku
T-Kisaku

Posted on

NextAuth: Custom user data

I want to use custom user data but, I faced a trap. So I want to show you.

export default NextAuth({
  providers: [
    // ...some probiders
  ],
  callbacks: {
    async signIn({ user, account, profile, email, credentials }){
      // You cannot use spread syntax
      // user = {...[Your variable]}
      user.[Your variable] = {
        // ...some properties
      }
    },
    async jwt({ token, user }){
      // You cannot use spread syntax
      // token = {...user.[Your variable]}
      token.[Your variable] = user.[Your variable]
    },
    async session({ session, token }){
      // You cannot use spread syntax
      // session = {...token.[Your variable]}
      session.[Your variable] = token.[Your variable]
    }
  }
})
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

πŸ‘‹ Hey, my name is Noah and I’m the one who set up this ad. My job is to get you to join DEV, so if you fancy doing me a favor, I’d love for you to create an account.

If you found DEV from searching around, here are a couple of our most popular articles on DEV: