Skip to main content
SQLite is a lightweight, serverless, self-contained SQL database. Better Auth uses Kysely under the hood for SQLite, which means any database Kysely supports is also supported by Better Auth. SQLite is a good fit for:
  • 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. The most widely used synchronous SQLite driver for Node.js.
1

Install the driver

2

Configure Better Auth

auth.ts

Node.js built-in SQLite (experimental)

The node:sqlite module is experimental and may change at any time. It requires Node.js 22.5.0 or later.
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

Use bunx --bun auth@latest generate (with the --bun flag) to prevent type errors related to the bun:sqlite module.
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.
Both schema generation and migration are supported for SQLite:
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 SQL JOIN clauses to fetch related data in a single query instead of multiple round-trips.
auth.ts
You may need to run migrations after enabling joins, as the feature may require updated schema columns.