Agent skill · software engineering · aiskillstore

better-auth-best-practices

Configure Better Auth server and client, set up database adapters, manage sessions, add plugins, and handle environment variables. Use when users mention Better Auth, betterauth, auth.ts, or need to set up TypeScript authentication with email/password, OAuth, or plugin configuration.

Why this skill is useful

Provides specific commands and configuration patterns for integrating Better Auth with TypeScript applications that the AI wouldn't reliably generate on its own.

What it needs

Requires better-auth installed locally. About 3k tokens when loaded. Last updated 2026-08-07. 405 stars on the source repository.

What this skill does

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: BETTERAUTHSECRET and BETTERAUTHURL 3. Create auth.ts with database + config 4. Create route handler for your framework 5. Run migrations: Built-in adapter: npx @better-auth/cli@latest migrate Drizzle: npx @better-auth/cli@latest generate --output src/db/auth-schema.ts then npx drizzle-kit push (dev) or npx drizzle-kit generate && npx drizzle-kit migrate (prod) Prisma: npx @better-auth/cli@latest generate --output prisma/schema.prisma then npx prisma migrate dev 6. Verify: call GET /api/auth/ok — should return { status: "ok" } --- Quick Reference Environment Variables BETTERAUTHSECRET - Encryption secret (min 32 chars). Generate: openssl rand -base64 32 BETTERAUTHURL - Base URL (e.g., https://example.com) Only define baseURL/secret in config if env vars are NOT set. File Location CLI looks for auth.ts in: ./, ./lib, ./utils, or under ./src. Use --config for custom path. CLI Commands npx @better-auth/cli@latest migrate - Apply schema (built-in adapter) npx @better-auth/cli@latest generate - Generate schema for Prisma/Drizzle npx @better-auth/cli mcp --cursor - Add MCP to AI tools Re-run after adding/changing plugins. --- Core Config Options Option Notes -------- ------- appName Optional display name baseURL Only if BETTERAUTHURL not set basePath Default /api/auth. Set / for root. secret Only if BETTERAUTHSECRET not set database Required for most features. See adapters docs. secondaryStorage Redis/KV for sessions & rate limits emailAndPassword { enabled: true } to activate socialProviders { google: { clientId, clientSecret }, ... } plugins Array of plugins trustedOrigins CSRF whitelist --- Database Direct connections: Pass pg.Pool, mysql2 pool, better-sqlite3, or bun:sqlite instance. For Postgres, also supports postgres (postgres.js) and @neondatabase/serverless. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills aiskillstore/better-auth-best-practices

View the source on GitHub

Browse the @skills marketplace