Features
- Minimal abstraction over session management
- Works with any database and framework
- Runtime-agnostic (Node, Bun, Deno, edge)
- Full control over auth flow and data model
Pros
- Maximum flexibility and control
- No vendor lock-in or opinionated structure
- Lightweight with clear, understandable code
Cons
- Requires more manual implementation than Clerk or Auth.js
- No pre-built UI components
- Steeper learning curve for auth newcomers
Overview
Lucia is a lightweight authentication library focused on session management. Unlike full-featured auth platforms, Lucia provides the minimal building blocks for authentication โ session creation, validation, and invalidation โ letting you control everything else.
Lucia works with any database, any framework, and any runtime. You define your own user model, choose your own password hashing, and build your own login forms. This approach gives experienced developers full control while keeping the authentication layer simple and auditable.
When to Use
Lucia is the right choice when you want full control over your authentication implementation, when youโre comfortable building auth flows yourself, or when you need auth that works across uncommon frameworks or runtimes. For faster setup, consider Auth.js or Clerk.
Getting Started
npm install lucia
import { Lucia } from "lucia";
const lucia = new Lucia(adapter, {
sessionCookie: {
attributes: { secure: process.env.NODE_ENV === "production" },
},
});
const session = await lucia.createSession(userId, {});
const cookie = lucia.createSessionCookie(session.id);