Database
A database is required for storing your users and sessions. Lucia connects to your database via an adapter, which provides a set of basic, standardized querying methods that Lucia can use.
import { Lucia } from "lucia";
import { BetterSqlite3Adapter } from "@lucia-auth/adapter-sqlite";
const lucia = new Lucia(new BetterSqlite3Adapter(db));
See Adapter
for building your own adapters.
Database setup
Refer to these guides on setting up your database, ORMs, and query builders:
- Drizzle ORM
- Kysely
- MongoDB
- Mongoose
- MySQL:
mysql2
, PlanetScale serverless - PostgreSQL: Neon HTTP serverless driver, node-postgres (
pg
), Postgres.js (postgres
) - Prisma
- SQLite:
better-sqlite3
, Bun SQLite (bun:sqlite
), Cloudflare D1, LibSQL (Turso)
Community-maintained database adapters
These adapters are not routinely checked by the maintainers of Lucia. Make sure to check the source code and use them at your own risk!