Extending next-auth user

I'm trying to extend the next-auth user but somehow It's not returning new fields, and I only have this with drizzle with prisma It's working fine.

declare module "next-auth" {
  interface Session extends DefaultSession {
    user: {
      id: string;
      // ...other properties
      displayName: string;
    } & DefaultSession["user"];
  }

  interface User {
    // ...other properties
    displayName: string;
  }
}

  callbacks: {
    session: ({ session, user }) => {
      console.log(user);
      console.log(user.displayName);

      return {
        ...session,
        user: {
          ...session.user,
          displayName: user.displayName,
          id: user.id,
        },
      };
    },
  },


Output:
{
  id: '965a6ae9-375f-40df-a527-af2e5a31db83',
  name: 'thoo0224',
  email: 'xxx@gmail.com',
  emailVerified: 2024-04-02T14:34:00.000Z,
  image: 'https://cdn.discordapp.com/xxx'
}
undefined
Was this page helpful?