Next.js Discord

Discord Forum

Simple custom adapter for NextAuth

Unanswered
Barbary Lion posted this in #help-forum
Open in Discord
Barbary LionOP
I'm trying to do a basic extension of NextAuth's createUser adapter. Do I put it in lib/auth.ts? How do I ensure it overrides the primary implementation?

1 Reply

Barbary LionOP
I'm trying this:

export function PrismaWrapper(
prisma: PrismaClient | ReturnType<PrismaClient["$extends"]>
): Adapter {
return {
createUser: async (user: User) => {
const name = user.name || ${user.email?.split("@")[0]};
const updatedUser: ExtendedUser = { ...user, name, role: "USER" };
return await PrismaAdapter(prisma).createUser(updatedUser);
},
};
}