Next.js Discord

Discord Forum

Adapter Error in next-auth

Answered
Mugger Crocodile posted this in #help-forum
Open in Discord
Mugger CrocodileOP
I'm currently using v5 beta(18) of next-auth. I'm trying to setup social auth with google and I'm using neon db along with prims as edge runtime..

auth.ts
import { Prisma } from "@prisma/client";
import { PrismaAdapter } from "@auth/prisma-adapter";
import NextAuth from "next-auth";
import Google from "next-auth/providers/google";

export const { handlers, signIn, signOut, auth } = NextAuth({
  adapter: PrismaAdapter(Prisma),
  providers: [Google],
});


prisma.ts
import { PrismaClient } from "@prisma/client";
import { Pool } from "@neondatabase/serverless";
import { PrismaNeon } from "@prisma/adapter-neon";

const prismaClientSingleton = () => {
  const neon = new Pool({ connectionString: process.env.POSTGRES_PRISMA_URL });
  const adapter = new PrismaNeon(neon);

  return new PrismaClient({ adapter });
};

declare global {
  var prisma: undefined | ReturnType<typeof prismaClientSingleton>;
}

const prisma = globalThis.prisma ?? prismaClientSingleton();

export default prisma;

if (process.env.NODE_ENV !== "production") globalThis.prisma = prisma;
Answered by Mugger Crocodile
nvm fixed it I had wrong import in adapter: PrismaAdapter(prisma)
View full answer

2 Replies

Mugger CrocodileOP
I'm following CodingInFlow's tutorial...
Mugger CrocodileOP
nvm fixed it I had wrong import in adapter: PrismaAdapter(prisma)
Answer