Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Better Auth · Const

prismaAdapter

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.

How it works

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.

Syntax

prismaAdapter(prisma, { provider: "postgresql" })

Parameters

NameTypeDescription
prismaPrismaClientThe initialized Prisma Client instance used to access the application database.
optionsobjectAdapter configuration, including the database provider such as postgresql, mysql, or sqlite.

Returns

A Better Auth database adapter configured to use the supplied Prisma Client.

Key points

  • Install the separate @better-auth/prisma-adapter package before importing prismaAdapter.
  • The first argument should be the initialized Prisma Client instance used by the application.
  • Configure the returned adapter under betterAuth's database option.
  • When Prisma uses a custom generated-client output path, import PrismaClient from that path instead of assuming the default package location.
  • After updating the schema, run Prisma's migration workflow and regenerate the client.

Common mistakes

  • Prisma 7 requires the current driver-adapter setup shown by the guide, while Prisma 6 and earlier can keep an existing Prisma Client setup without a driver adapter.

Example: Configure Better Auth with Prisma

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.

When to use it

PostgreSQL authentication storage

Use an existing Prisma-backed PostgreSQL application as Better Auth's persistence layer.

Local Prisma development

Connect Better Auth to a development database managed through Prisma.

ORM-managed schema lifecycle

Keep authentication persistence inside an application's existing ORM and migration workflow.

Interview questions

QWhat does prismaAdapter do?

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.

QHow do you configure Prisma for Better Auth?

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.

QHow are schema changes handled with the Prisma adapter?

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.

  • betterAuth
  • PrismaClient
  • @better-auth/prisma-adapter
  • PrismaPg
  • auth generate

Source: Prisma | Better Auth. Checked 2026-10-15.