Documentation

Server Configuration

Database adapter, providers, and database commands for the server.

Server Configuration

Database Adapter

By default, the server uses PostgreSQL with Prisma. You can customize providers or swap the ORM if needed.

// apps/server/src/lib/auth.ts
import { prismaAdapter } from "better-auth/adapters/prisma";
import { prisma } from "@repo/database";

export const auth = betterAuth({
  // ... other config
  database: prismaAdapter(prisma, {
    provider: "postgresql",
  }),
});
  • Default provider: PostgreSQL (works great with Supabase)
  • ORM: Prisma (you may switch to Drizzle if you prefer)
  • Fully customizable: replace the adapter/provider to fit your infra

Providers

  • PostgreSQL: recommended default, compatible with Supabase
  • Prisma: schema-first, powerful tooling (migrations, studio)
  • Drizzle: optional alternative if you prefer SQL-first ergonomics

Database Commands (run from repo root)

Each command targets the server package via Turbo filter. Run them one-by-one as needed.

1) Push schema (fast local iteration)

pnpm run db:push
  • Applies the current Prisma schema to your database without creating a migration.
  • Best for local development only. Do not use for production changes.

2) Open Prisma Studio (data browser)

pnpm run db:studio
  • Opens Prisma Studio to browse and edit your data visually.
  • Handy for quick inspections and manual tweaks during development.

3) Generate Prisma Client

pnpm run db:generate
  • Generates a fresh Prisma Client from your current schema.
  • Run after schema changes if the client types need to be regenerated.

4) Create and apply a migration (production-safe)

pnpm run db:migrate
  • Creates a migration file and applies it to your database.
  • Use for shared environments and production to track schema changes safely.

Notes

  • Ensure your database URL is set in environment variables before running commands.
  • Prefer migrations (db:migrate) for shared environments; use db:push only during local iteration.
  • If switching to Drizzle, mirror these workflows with Drizzle kit commands.