Replies: 1 comment
-
I had the same exact problem, and it was fixed by ensuring that the Before (Incorrect Approach):import NextAuth from "next-auth";
declare module "next-auth" {
interface Session {
user: {
id: string; // Custom 'id' property, but missing default user properties
};
}
} In this approach, the After (Correct Approach):import NextAuth, { DefaultSession } from "next-auth";
declare module "next-auth" {
interface Session {
user: {
id: string; // Custom 'id' property
} & DefaultSession['user']; // Extending with default user properties from DefaultSession
}
}
Conclusion:To add custom properties (like This is the correct way to modify the |
Beta Was this translation helpful? Give feedback.
-
As per the next-auth-example, I've run a script to copy the relevant functionality to my project and managed the requisite dependencies. However, I'm getting errors in the
[...nextauth]
file that can't seem to go away. Here is a minimal repository for this.On the line:
import NextAuth, { NextAuthOptions } from "next-auth"
I'm getting:Module '"next-auth"' has no exported member 'NextAuthOptions'.
And on:
export default NextAuth(authOptions)
, I'm getting:This expression is not callable. Type 'typeof import("c:/path/next-auth")' has no call signatures.
Here's my code:
Insight on how to fix? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions