PostgreSQL

Setup Better Auth with PostgreSQL.

Installation

Install Better Auth with PostgreSQL, or PostgreSQL + Redis as a secondary storage (caching).

code-editor
pnpm dlx shadcn@latest add @auth-cn/postgres

Better Auth + PostgreSQL

code-editor
pnpm dlx shadcn@latest add @auth-cn/postgres-redis

Better Auth + PostgreSQL + Redis as a secondary storage (caching)

Schema Generation & Migration

The Better Auth CLI allows you to generate and migrate your database schema based on your Better Auth configuration and installed plugins.

PostgreSQL supports both schema generation and schema migration

code-editor
pnpm dlx @better-auth/cli@latest generate

Generate PostgreSQL Schema

code-editor
pnpm dlx @better-auth/cli@latest migrate

Migrate PostgreSQL Schema