Skip to content

override User or DefaultUser type #8923

Answered by nktnet1
aboyo asked this question in Help
Discussion options

You must be logged in to vote

For next-auth v4.24.10 and v5.0.0-beta.25, I'm using the following:

/* eslint-disable @typescript-eslint/no-unused-vars */
import { JWT } from "next-auth/jwt"
import NextAuth, { DefaultSession, User } from 'next-auth';

export interface CustomAuthUser extends User {
  id: string;
}

declare module 'next-auth' {
  interface Session {
    user?: CustomAuthUser & DefaultSession['user'];
  }
}

declare module 'next-auth/jwt' {
  interface JWT {
    user?: CustomAuthUser;
  }
}

Bear in mind that your versions of @auth/drizzle-adapter and @auth/core, if you're using them in your project could affect the above - e.g.

and if these can't …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by aboyo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants