- Local development and testing
- Serverless edge runtimes (Cloudflare D1)
- Embedded or single-user applications
Drivers
Better Auth accepts any of the SQLite drivers listed below. Choose the one that matches your runtime.better-sqlite3 (recommended)
The most widely used synchronous SQLite driver for Node.js.1
Install the driver
- npm
- pnpm
- yarn
2
Configure Better Auth
auth.ts
Node.js built-in SQLite (experimental)
Starting from Node.js 22.5.0 you can use the built-in SQLite module without installing a package:auth.ts
Bun built-in SQLite
Bun ships with a built-in SQLite module:auth.ts
Schema generation and migration
The Better Auth CLI can both generate the schema and apply migrations directly to your SQLite file.- migrate
- generate
generate produces a SQL file you can inspect and apply manually. migrate runs the SQL directly against your database file.Cloudflare D1
Cloudflare D1 is a SQLite-compatible edge database. Because D1 can only be accessed from a Cloudflare Worker, the CLI cannot run migrations against it directly. Use programmatic migrations instead:auth.ts
src/index.ts
Experimental joins
Enabling joins allows Better Auth to use SQLJOIN clauses to fetch related data in a single query instead of multiple round-trips.
auth.ts