New Prisma generate and init
i receved an error when
npx @better-auth/cli generate
with a new version of Prisma.
8 Replies
Please use your generated client on the auth config for initializing the adapters db
If you do have a custom one
Don't use @prisma/client
Just use your generated client path
And import Prisma client from there
import { PrismaClient } from "@prisma/client";
const globalForPrisma = global as unknown as { prisma: PrismaClient };
export const prisma =
globalForPrisma.prisma || new PrismaClient();
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
this is my /lib/prisma.ts
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { prisma } from "@/lib/prisma";
export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: "postgresql",
}),
emailAndPassword: {
enabled: true,
},
});
and this is my auth.tsShow me your schema.prisma ?
generator client {
provider = "prisma-client-js"
output = "../app/generated/prisma"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
}
So use the output path which is your new client for auth config
Instead of using Prisma client the default one
how?
like import the Prisma client not from @prisma/client .but from generated/prisma
On your auth config
thanks bro. i solved it.