Backend
3,497 installs
Better Auth Integration Guide
by better-auth/skills
Configure Better Auth server and client, set up database adapters, manage sessions, add plugins, and handle environment variables. Use when users mention…
Skill content
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
Better Auth Integration Guide
Always consult better-auth.com/docs for code examples and latest API.
Setup Workflow
- Install: npm install better-auth
- Set env vars: BETTER_AUTH_SECRET and BETTER_AUTH_URL
- Create auth.ts with database + config
- Create route handler for your framework
- Run npx @better-auth/cli@latest migrate
- Verify: call GET /api/auth/ok - should return { status: "ok" }
Quick Reference