← ClaudeAtlas

api-auth-better-auth-drizzle-honolisted

Better Auth patterns, sessions, OAuth
agents-inc/skills · ★ 18 · API & Backend · score 77
Install: claude install-skill agents-inc/skills
# 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)** **(You MUST use `auth.$Infer.Session` types for type-safe session access in middleware)** </critical_requirements> --- **Auto-detection:** Better Auth, betterAuth, createAuthClient, auth.handler, auth.api.getSession, socialProviders, twoFactor plugin, organization plugin, drizzleAdapter, session management, OAuth providers, stateless sessions, cookieCache, genericOAuth, oAuthProvider, passkey, SCI