Next-Auth extending user
When I try to extend the user interface of next-auth I'm getting this error on the adapter in NextAuthOptions:
code:
Property 'credits' is missing in type 'import("C:/Users/Thoma/Desktop/iconmasterai/node_modules/.pnpm/@[email protected]/node_modules/@auth/core/adapters").AdapterUser' but required in type 'import("C:/Users/Thoma/Desktop/iconmasterai/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/adapters").AdapterUser'.
Property 'credits' is missing in type 'import("C:/Users/Thoma/Desktop/iconmasterai/node_modules/.pnpm/@[email protected]/node_modules/@auth/core/adapters").AdapterUser' but required in type 'import("C:/Users/Thoma/Desktop/iconmasterai/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/adapters").AdapterUser'.
declare module "next-auth" {
interface Session extends DefaultSession {
user: {
id: string;
credits: number;
} & DefaultSession["user"];
}
interface User {
credits: number;
}
}
export const authOptions: NextAuthOptions = {
callbacks: {
session: ({ session, user }) => ({
...session,
user: {
...session.user,
id: user.id,
},
}),
},
adapter: DrizzleAdapter(db),
providers: [
DiscordProvider({
clientId: env.DISCORD_CLIENT_ID,
clientSecret: env.DISCORD_CLIENT_SECRET,
}),
],
};
declare module "next-auth" {
interface Session extends DefaultSession {
user: {
id: string;
credits: number;
} & DefaultSession["user"];
}
interface User {
credits: number;
}
}
export const authOptions: NextAuthOptions = {
callbacks: {
session: ({ session, user }) => ({
...session,
user: {
...session.user,
id: user.id,
},
}),
},
adapter: DrizzleAdapter(db),
providers: [
DiscordProvider({
clientId: env.DISCORD_CLIENT_ID,
clientSecret: env.DISCORD_CLIENT_SECRET,
}),
],
};
0 Replies