better-auth-best-practices

Configure Better Auth servers, clients, database adapters, sessions, and plugins for TypeScript applications.

Updated Jul 29, 2026
One-click install
npx skills add https://github.com/zomeru/zomlab --skill better-auth-best-practices-zomeru
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: better-auth-best-practices
Source: https://github.com/zomeru/zomlab/tree/main/.agents/skills/better-auth-best-practices
Command: npx skills add https://github.com/zomeru/zomlab --skill better-auth-best-practices-zomeru

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires better-auth, @better-auth/cli.

What problem does it solve? Setting up TypeScript authentication with Better Auth involves many moving parts—environment variables, database adapters, session strategies, plugins, and migrations—and misconfiguration leads to broken logins, missing schema tables, or insecure sessions. This Skill provides a structured reference covering the full setup workflow and common pitfalls. ## Core Features & Use Cases - Setup Workflow: Step-by-step installation, environment variable configuration, auth.ts creation, route handler setup, and CLI migrations for built-in, Drizzle, and Prisma adapters. - Session & Security Configuration: Guidance on cookie cache strategies (compact, JWT, JWE), secondary storage, rate limiting, CSRF, and cross-subdomain cookies. - Plugins & Client Integration: Tree-shakeable plugin imports (twoFactor, organization, magicLink, passkey) and framework-specific client setup for React, Vue, Svelte, and Solid. - Use Case: You are adding email/password plus Google OAuth to a Hono API backed by Drizzle and Neon Postgres. Use this Skill to generate the auth schema, configure the Drizzle adapter with the correct provider, and verify the setup via the /api/auth/ok endpoint. ## Quick Start Set up Better Auth in my TypeScript project with email and password sign-in, a Drizzle PostgreSQL adapter, and session cookie caching.

Frequently Asked Questions about better-auth-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up Better Auth with a database?▼

Install better-auth, set BETTER_AUTH_SECRET and BETTER_AUTH_URL, create an auth.ts with your database config, and add a route handler. Run npx @better-auth/cli migrate for the built-in adapter, or generate schema for Drizzle or Prisma and apply it with their migration tools.

How to configure Better Auth with Drizzle ORM?▼

Import the adapter from better-auth/adapters/drizzle and pass a db instance from drizzle() with a provider of pg, mysql, or sqlite matching your driver. Generate the schema with the Better Auth CLI, then run drizzle-kit push in development or generate and migrate in production.

Does Better Auth support OAuth social providers?▼

Yes, Better Auth supports social providers such as Google and GitHub through the socialProviders config option with clientId and clientSecret. The genericOAuth plugin covers additional providers, and account.storeAccountCookie enables stateless OAuth flows.

Why does Better Auth use the wrong table name with Prisma?▼

Better Auth config references ORM model names, not underlying database table names. If your Prisma model is User mapping to a users table, set modelName to user, not users, in the configuration.

Do I need to re-run migrations after adding Better Auth plugins?▼

Yes, plugins can add their own schema tables and fields, so you must re-run the Better Auth CLI generate or migrate command after adding or changing plugins. Skipping this step causes missing-table errors at runtime.

Can Better Auth work without a database?▼

Yes, Better Auth supports a fully stateless mode where sessions live only in the cookie cache when no database is configured. Logout then depends on cache expiry, and custom session fields are always re-fetched rather than cached.