© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Theo's Typesafe CultTTC
Theo's Typesafe Cult•3y ago•
6 replies
Mads

Add rest of User prisma table types and data to nextauth session in auth.ts

Hi, how can I add all the user data to the session including user table specified values and not just nextAuth?

My current setup in the scaffolded T3 auth.ts is the following:

declare module "next-auth" {
  interface Session extends DefaultSession {
    user: {
      id: number;
      gender: boolean | null;
      birthdate: string | null;
      // ...other properties
      // role: UserRole;
    } & DefaultSession["user"];
  }
}
declare module "next-auth" {
  interface Session extends DefaultSession {
    user: {
      id: number;
      gender: boolean | null;
      birthdate: string | null;
      // ...other properties
      // role: UserRole;
    } & DefaultSession["user"];
  }
}

/**
 * Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
 *
 * @see https://next-auth.js.org/configuration/options
 */
export const authOptions: NextAuthOptions = {
  callbacks: {
    session: ({ session, user }) => ({
      ...session,
      user: {
        ...session.user,
        ...user,
        id: parseInt(user.id)
      },
    }),
  },
  adapter: PrismaAdapter(prisma),
  providers: [
    GoogleProvider({
      clientId: env.GOOGLE_CLIENT_ID,
      clientSecret: env.GOOGLE_CLIENT_SECRET,
    }),
    LinkedInProvider({
      clientId: env.LINKEDIN_CLIENT_ID,
      clientSecret: env.LINKEDIN_CLIENT_SECRET,
    }),
    /**
     * ...add more providers here.
     *
     * Most other providers require a bit more work than the Discord provider. For example, the
     * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account
     * model. Refer to the NextAuth.js docs for the provider you want to use. Example:
     *
     * @see https://next-auth.js.org/providers/github
     */
  ],
  pages: {
    signIn: '/auth/signin'
  }
};
/**
 * Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
 *
 * @see https://next-auth.js.org/configuration/options
 */
export const authOptions: NextAuthOptions = {
  callbacks: {
    session: ({ session, user }) => ({
      ...session,
      user: {
        ...session.user,
        ...user,
        id: parseInt(user.id)
      },
    }),
  },
  adapter: PrismaAdapter(prisma),
  providers: [
    GoogleProvider({
      clientId: env.GOOGLE_CLIENT_ID,
      clientSecret: env.GOOGLE_CLIENT_SECRET,
    }),
    LinkedInProvider({
      clientId: env.LINKEDIN_CLIENT_ID,
      clientSecret: env.LINKEDIN_CLIENT_SECRET,
    }),
    /**
     * ...add more providers here.
     *
     * Most other providers require a bit more work than the Discord provider. For example, the
     * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account
     * model. Refer to the NextAuth.js docs for the provider you want to use. Example:
     *
     * @see https://next-auth.js.org/providers/github
     */
  ],
  pages: {
    signIn: '/auth/signin'
  }
};


Is this the correct way to add the prisma table colum types and data to the session?
Solution
Hi, how can I add all the user data to the session including user table specified values and not just nextAuth?

My current setup in the scaffolded T3 auth.ts is the following:

declare module "next-auth" {
  interface Session extends DefaultSession {
    user: {
      id: number;
      gender: boolean | null;
      birthdate: string | null;
      // ...other properties
      // role: UserRole;
    } & DefaultSession["user"];
  }
}
declare module "next-auth" {
  interface Session extends DefaultSession {
    user: {
      id: number;
      gender: boolean | null;
      birthdate: string | null;
      // ...other properties
      // role: UserRole;
    } & DefaultSession["user"];
  }
}

/**
 * Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
 *
 * @see https://next-auth.js.org/configuration/options
 */
export const authOptions: NextAuthOptions = {
  callbacks: {
    session: ({ session, user }) => ({
      ...session,
      user: {
        ...session.user,
        ...user,
        id: parseInt(user.id)
      },
    }),
  },
  adapter: PrismaAdapter(prisma),
  providers: [
    GoogleProvider({
      clientId: env.GOOGLE_CLIENT_ID,
      clientSecret: env.GOOGLE_CLIENT_SECRET,
    }),
    LinkedInProvider({
      clientId: env.LINKEDIN_CLIENT_ID,
      clientSecret: env.LINKEDIN_CLIENT_SECRET,
    }),
    /**
     * ...add more providers here.
     *
     * Most other providers require a bit more work than the Discord provider. For example, the
     * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account
     * model. Refer to the NextAuth.js docs for the provider you want to use. Example:
     *
     * @see https://next-auth.js.org/providers/github
     */
  ],
  pages: {
    signIn: '/auth/signin'
  }
};
/**
 * Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
 *
 * @see https://next-auth.js.org/configuration/options
 */
export const authOptions: NextAuthOptions = {
  callbacks: {
    session: ({ session, user }) => ({
      ...session,
      user: {
        ...session.user,
        ...user,
        id: parseInt(user.id)
      },
    }),
  },
  adapter: PrismaAdapter(prisma),
  providers: [
    GoogleProvider({
      clientId: env.GOOGLE_CLIENT_ID,
      clientSecret: env.GOOGLE_CLIENT_SECRET,
    }),
    LinkedInProvider({
      clientId: env.LINKEDIN_CLIENT_ID,
      clientSecret: env.LINKEDIN_CLIENT_SECRET,
    }),
    /**
     * ...add more providers here.
     *
     * Most other providers require a bit more work than the Discord provider. For example, the
     * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account
     * model. Refer to the NextAuth.js docs for the provider you want to use. Example:
     *
     * @see https://next-auth.js.org/providers/github
     */
  ],
  pages: {
    signIn: '/auth/signin'
  }
};


Is this the correct way to add the prisma table colum types and data to the session?
Jump to solution
Theo's Typesafe Cult banner
Theo's Typesafe CultJoin
26,131Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

NextAuth add additional property to session
Theo's Typesafe CultTTCTheo's Typesafe Cult / questions
3y ago
Types error with Image component and NextAuth session
Theo's Typesafe CultTTCTheo's Typesafe Cult / questions
4y ago
Nextauth add data to user that tries to sign up
Theo's Typesafe CultTTCTheo's Typesafe Cult / questions
3y ago
Prisma and NextAuth: Additional fields in the `User` model
Theo's Typesafe CultTTCTheo's Typesafe Cult / questions
3y ago