api-auth-better-auth-drizzle-hono
Authentication with Better Auth
Quick Guide: Use Better Auth (v1.5+) for type-safe, self-hosted authentication in TypeScript apps. It provides email/password, OAuth, 2FA, sessions, stateless auth, and organization multi-tenancy. Plugin architecture enables progressive complexity. Mount auth handler before session-dependent middleware, configure CORS first for cross-origin deployments, and always run schema generation after adding plugins.
<critical_requirements>
CRITICAL: Before Using This Skill
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST mount Better Auth handler on the auth route BEFORE any other middleware that depends on session)
(You MUST configure CORS middleware BEFORE auth routes when client and server are on different origins)
(You MUST use environment variables for ALL secrets (clientId, clientSecret, BETTER_AUTH_SECRET) - NEVER hardcode)
(You MUST run npx auth@latest generate then your ORM migration tool after adding plugins)