⚡ BolkAuth

Install the Prisma adapter:

Install command
$ pnpm add @bolkauth/adapter-prisma @prisma/client

Install the Prisma CLI as a development dependency:

Install command
$ pnpm add -D prisma

Auth Configuration

import { createBolkAuth } from "@bolkauth/core";
import { createPrismaAdapter } from "@bolkauth/adapter-prisma";
import { PrismaClient } from "@prisma/client";
 
const globalForPrisma = globalThis as unknown as {
  prisma?: PrismaClient;
};
 
export const prisma = globalForPrisma.prisma ?? new PrismaClient();
 
if (process.env.NODE_ENV !== "production") {
  globalForPrisma.prisma = prisma;
}
 
export const auth = createBolkAuth({
  adapter: createPrismaAdapter(prisma),
  secret: process.env.BOLKAUTH_SECRET!,
});

Schema Files

The package includes schema path exports:

import {
  postgresqlSchemaPath,
  mysqlSchemaPath,
  sqliteSchemaPath,
} from "@bolkauth/adapter-prisma";

Use the schema file that matches your datasource provider, or copy the models into your existing prisma/schema.prisma.

Required Models

Your Prisma schema must include models compatible with:

ModelPurpose
AuthUserUsers and password/email fields.
AuthSessionSession records keyed by token.
AuthAccountOAuth provider account links.
AuthVerificationTokenMagic-link and OTP tokens.
AuthUserMetadataKey/value metadata for onboarding and custom data.

Migration

npx prisma migrate dev --name add_bolkauth
npx prisma generate

For production:

npx prisma migrate deploy

Dialects

The adapter is designed for Prisma clients generated from PostgreSQL, MySQL, SQLite, or CockroachDB schemas. Make sure the DATABASE_URL and datasource provider agree.

On this page