Replies: 1 comment
-
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
and if these can't be updated, you may need to change declare module 'next-auth/jwt' { to declare module '@auth/core/jwt' { |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Hi all,
I am currently using next-auth to implement login functionality. I am using the CredentialsProvider along with my own API server to verify usernames and passwords. In the authorize function, I want to return my custom-defined user object.
I have added a
types/next-auth.d.ts
file in the project and declared the User type: (it just only has one property 'id')but, In the authorize function of the CredentialsProvider, user data can still have additional properties:
I have also tried declaring DefaultUser in the
types/next-auth.d.ts
file, but it didn't work.How do I customize the User type~?
// I'm using next-auth:^4.24.3
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions