Technical & DevelopmentIntermediate
better-auth-best-practices
Configure Better Auth server and client, set up database adapters, manage sessions, add plugins, and handle environment variables.
Developer Setup
Setup & Installation
bash
npx skills add https://github.com/better-auth/skills --skill better-auth-best-practicesnpx skills add https://github.com/better-auth/skills --skill better-auth-best-practicesOr paste this URL into your assistant to install:
Overview
What This Skill Does
Provides best practices for installing and configuring the Better Auth server and client, including database adapter setups, environment variable configuration, CLI migrations, and session management.
Application
When to use this Skill
- Integrating a type-safe authentication library in Next.js, Nuxt, Astro, Hono, or other TypeScript frameworks.
- Connecting your authentication logic directly to your own database (Prisma, Drizzle, MongoDB, or raw SQLite/Postgres).
- Managing session state using Redis/KV storage or stateless compact/JWT cookie caches.
- Scaffolding custom social login providers alongside username/password authentication.
- Ensuring database adapter model names correctly map to ORM structures without table-name drift.
Documentation
Show Skills.md file
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_SECRETandBETTER_AUTH_URL - Create
auth.tswith 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
Environment Variables
BETTER_AUTH_SECRET- Encryption secret (min 32 chars). Generate:openssl rand -base64 32BETTER_AUTH_URL- Base URL (e.g.,https://example.com)
Only define baseURL/secret in config if env vars are NOT set.
Lines 1 - 25 of 75
Recommendations