PostgreSQL authentication storage
Use an existing Prisma-backed PostgreSQL application as Better Auth's persistence layer.
Better Auth · Const
prismaAdapter connects Better Auth to Prisma by wrapping an initialized Prisma Client. Configure it as the auth database adapter and specify the matching database provider.
prismaAdapter connects Better Auth to an existing Prisma Client. Call it with that client and a provider option, then assign the returned adapter to the database field in betterAuth; the current guide demonstrates PostgreSQL with Prisma 7.
prismaAdapter(prisma, { provider: "postgresql" })| Name | Type | Description |
|---|---|---|
prisma | PrismaClient | The initialized Prisma Client instance used to access the application database. |
options | object | Adapter configuration, including the database provider such as postgresql, mysql, or sqlite. |
A Better Auth database adapter configured to use the supplied Prisma Client.
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { prisma } from "./prisma";
export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: "postgresql",
}),
});Pass the initialized Prisma Client to prismaAdapter and select the database provider used by the Prisma setup.
Use an existing Prisma-backed PostgreSQL application as Better Auth's persistence layer.
Connect Better Auth to a development database managed through Prisma.
Keep authentication persistence inside an application's existing ORM and migration workflow.
The adapter accepts a Prisma Client instance and configuration containing the database provider. The returned adapter is assigned to the database property of betterAuth.
Follow-up: Why must the provider be specified? The adapter uses it to interpret the Prisma-backed database configuration for the selected database dialect.
Install @better-auth/prisma-adapter, initialize Prisma, and pass that client to prismaAdapter. With the current Prisma 7 guide, the client is imported from the generated output path when a custom output is configured.
Follow-up: What changes with Prisma 6 or earlier? A driver adapter is optional, so an existing Prisma Client setup can remain unchanged.
Prisma and Drizzle adapters use ORM-specific migration tools rather than Better Auth's built-in Kysely migration mechanism. For Prisma, generate or migrate the schema with Prisma tooling.
Follow-up: How can the schema be generated? The Better Auth CLI can generate the required Prisma schema, and Prisma commands can then create the migration and regenerate the client.
betterAuthPrismaClient@better-auth/prisma-adapterPrismaPgauth generate