ADR-0003: Better Auth handles authentication
- Status: accepted
- Date: 2026-11-12
- Decided by: Stefan Imhoff
Context
Hotaru needs login and sessions for the browser, API tokens for the CLI, the TUI and local Pi agents, registration that is off by default, and invites for later users (SI-523, SI-564). The plan is to stay multi-user and maybe open source, so auth has to be solid, not a personal shortcut.
Konbini already runs Better Auth (1.7) with SvelteKit: cookie sessions through sveltekitCookies, sign-up closed by default, invite links, an admin role, and a CLI to create the first user. Its API tokens are a small table of its own (src/lib/server/api/tokens.ts), hashed and prefixed.
Decision
Use Better Auth with its Drizzle adapter on hotaru.db, set up like Konbini: email and password, sign-up off by default, invites, an admin role, and user:create as an admin CLI. API tokens for non-browser clients follow Konbini’s own token table (prefix hotaru_, hashed, read or write scope). They don’t use a Better Auth plugin, so the token format stays under our control.
Rejected alternatives
- Own sessions, following the Lucia guide. Lucia is deprecated as a library and now lives on as a guide for writing your own session code. That means full control and no dependency, but password hashing, reset, rate limits, invites and roles would all be ours to build and keep secure. Konbini already solved them with Better Auth.
- Auth.js (
@auth/sveltekit). Built around OAuth providers. Password login (the “credentials” provider) is limited on purpose and doesn’t create database sessions. As far as I know, Auth.js development moved to the Better Auth team in 2025, which makes Better Auth the more direct choice. Not verified for this ADR.
Consequences
- The setup, schema and tests can be copied from Konbini rather than written from scratch.
- Better Auth owns its tables (user, session, account, verification) in
hotaru.db. Their schema is generated with Better Auth’s CLI and committed as a Drizzle schema file, as in Konbini (auth-schema.ts). - Upgrades follow Better Auth’s releases. Both Konbini and Hotaru use it, so one upgrade is tested twice.
BETTER_AUTH_SECRET,BETTER_AUTH_URLandORIGINare required in production (see Konbini’sdocs/deployment.md).