Adapters
Store Radon's data in any database — MongoDB, PostgreSQL, MySQL, SQLite, Prisma, Supabase, or Firebase. One small contract; swap freely.
An adapter is the bridge between Radon and your database. It's a small set of methods Radon calls to read and write users, identities, codes, and sessions. Because that contract is all Radon depends on, you can switch databases without touching your auth code.
import { postgresAdapter } from "@radonsdk/auth/adapters/postgres";
adapter: postgresAdapter(pool)Radon never stores plaintext secrets
Codes and session tokens are hashed (SHA-256) before they reach the adapter, and passwords are bcrypt-hashed. Your database only ever holds hashes — a leak never exposes a live credential.
Built-in adapters
Each adapter takes an already-instantiated client and lives at its own import path.
import { postgresAdapter } from "@radonsdk/auth/adapters/postgres";
import { Pool } from "pg";
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
export const auth = new Radon({
adapter: postgresAdapter(pool),
session: { secret: process.env.RADON_SECRET! },
// ...
});
await auth.init(); // creates the tables (safe to re-run)Takes a pg Pool. Ids are UUIDs, metadata is jsonb, timestamps are
timestamptz.
Use a service-role / server key
Adapters run on your server and need full read/write access. For Supabase use the service-role key (never the anon key), and keep every adapter client server-side.
Table prefix
SQL adapters prefix their tables with radon_ by default. Override it if you need
to share a database:
adapter: postgresAdapter(pool, { tablePrefix: "auth_" });
// Mongo uses `collectionPrefix` instead.init() — creating tables
Call await auth.init() once (a migration script or server boot) to create the
tables for the SQL adapters. It's idempotent — safe to run repeatedly.
- Postgres / MySQL / SQLite —
init()creates the tables for you. - Prisma / Supabase — you own the schema (migrations / SQL);
init()is a no-op for tables. - Firebase — schemaless; nothing to create.
Pro features need a few extra methods
The Pro session/org/API-key/deletion features call additional adapter methods.
All seven built-in adapters (plus the in-memory reference) implement them. A
custom adapter missing a method throws a clear AdapterCapabilityError naming
the method and feature — nothing fails silently.
In-memory adapter (tests)
For unit tests and quick experiments, an in-memory adapter needs no database:
import { memoryAdapter } from "@radonsdk/auth/adapters/memory";
adapter: memoryAdapter()It implements the full contract (including Pro methods) but forgets everything on restart — never use it in production.
Writing a custom adapter
Implement the RadonAdapter interface (exported from @radonsdk/auth) — the
core methods cover users, identities, codes, and sessions; the optional ones back
Pro features. The built-in adapters are the reference implementations if you're
adding a database Radon doesn't ship.