20 · Integrations
Better Auth — or just use forge/auth
forge/auth ships Password, JWT, SessionManager, OAuth2 PKCE, TOTP, WebAuthn, RBAC, ApiKeyAuth, BackupCodes, AdaptiveMFA — 34 APIs, zero deps.
Code
better-auth.js
const { WebApp } = require(class="tk-str">39;@hyperbridge/forge/server39;); const { Password, JWT } = require(class="tk-str">39;@hyperbridge/forge/auth39;); const app = new WebApp(); const users = new Map(); app.post(class="tk-str">39;/signup39;, async (c) => { const { email, password } = await c.req.json(); users.set(email, { hash: await Password.hash(password) }); return c.json({ token: JWT.sign({ email }, process.env.JWT_SECRET), }); }); app.post(class="tk-str">39;/login39;, async (c) => { const { email, password } = await c.req.json(); const u = users.get(email); if (!u || !(await Password.verify(password, u.hash))) { return c.json({ error: class="tk-str">39;invalid39; }, 401); } return c.json({ token: JWT.sign({ email }, process.env.JWT_SECRET), }); }); app.listen(3000);
How it works
Password.hash uses argon2id by default with sane work factors (memory: 64MB, time: 3 iterations).
JWT.sign and JWT.verify are built on Web Crypto, so they work identically on Node, Bun, Deno, and CF Workers — no native binary.
For sessions instead of JWTs, swap to SessionManager with a backing store (memory, Redis, file, or your own driver).
Try it
Quickstart
curl -X POST http://localhost:3000/signup -d '{"email":"a@b.c","password":"…"}'
Related modules
This is HBForge's port of Hono's example. Read the original at hono.dev/examples/better-auth.