Installation
Configuration options
ThedrizzleAdapter function accepts a Drizzle db instance and a config object:
| Option | Type | Description |
|---|---|---|
provider | "pg" | "mysql" | "sqlite" | The database provider. Required. |
schema | Record<string, any> | Override the auto-detected schema. Useful when table names differ from model names. |
usePlural | boolean | Set to true when all your table exports use plural names (e.g. users instead of user). |
camelCase | boolean | Use camelCase for generated field names instead of snake_case. Defaults to false. |
debugLogs | boolean | Enable verbose adapter logging. Defaults to false. |
transaction | boolean | Wrap multi-step operations in a database transaction. Defaults to false. |
Schema generation
The Better Auth CLI generates the required Drizzle schema based on your auth configuration and any plugins you have enabled.- generate migration
- apply migration
Schema examples
The tables below are whatnpx auth@latest generate produces for each provider.
- PostgreSQL
- MySQL
- SQLite
schema.ts
Modifying table names
If your Drizzle schema uses different table export names (for exampleusers instead of user), pass the schema object and remap the key:
auth.ts
modelName directly in the auth config:
auth.ts
Modifying field names
Better Auth maps field names using the property name you assign in your Drizzle schema. To rename a column in the database without changing the property name, update the column string argument:auth.ts
Using plural table names
If every table in your schema uses a plural name, passusePlural: true instead of remapping each model:
auth.ts
Experimental joins
Enabling joins allows Better Auth to fetch related data in a single query rather than issuing multiple round-trips. Endpoints such as/get-session and /get-full-organization see 2-3x latency improvements.
auth.ts