better-auth-best-practices

Installation
Summary

Complete Better Auth server and client setup with database adapters, session management, plugins, and security configuration.

  • Covers full workflow from installation through database migration, environment variable setup, and route handler creation across multiple frameworks
  • Supports multiple database adapters (Prisma, Drizzle, MongoDB, direct connections) with critical guidance on model vs. table naming conventions
  • Includes session storage strategies with secondary storage (Redis/KV), cookie caching modes (compact, JWT, JWE), and stateless operation options
  • Provides 10+ popular plugins (two-factor, organization, passkey, magic link, OAuth provider, SSO) with tree-shaking imports and client-side integration
  • Features before/after hooks at endpoint and database levels, rate limiting configuration, CSRF/origin security controls, and type-safe client methods across vanilla, React, Vue, Svelte, and Solid frameworks
SKILL.md

Better Auth Integration Guide

Always consult better-auth.com/docs for code examples and latest API.


Setup Workflow

  1. Install: npm install better-auth
  2. Set env vars: BETTER_AUTH_SECRET and BETTER_AUTH_URL
  3. Create auth.ts with database + config
  4. Create route handler for your framework
  5. Run npx @better-auth/cli@latest migrate
  6. Verify: call GET /api/auth/ok — should return { status: "ok" }

Quick Reference

Related skills

More from better-auth/skills

Installs
48.9K
GitHub Stars
189
First Seen
Jan 19, 2026