better-auth-best-practices

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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 misconfigurations cause subtle bugs like sessions stored in the wrong place or schema mismatches. ## Core Features & Use Cases - Server & Client Setup: Guides installation, auth.ts creation, route handlers, and framework-specific client imports (React, Vue, Svelte, Solid). - Database & Session Management: Covers Drizzle, Prisma, and direct driver adapters, CLI schema generation, cookie cache strategies, and secondary storage. - Plugins & Security: Details plugin imports, hooks, rate limiting, CSRF, and common gotchas like model-name vs table-name confusion. - Use Case: When adding email/password and Google OAuth login to a SvelteKit app backed by Neon PostgreSQL and Drizzle, use this Skill to generate the correct auth config, run migrations, and avoid session storage pitfalls. ## Quick Start Set up Better Auth in my TypeScript project with a Drizzle adapter, email and password sign-in, and Google OAuth.

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. Then run the CLI migrate command for the built-in adapter or generate schema for Drizzle or Prisma.

How to run Better Auth migrations with Drizzle?

Run npx @better-auth/cli@latest generate --output src/db/auth-schema.ts, then use drizzle-kit push in development or drizzle-kit generate plus migrate in production. A drizzle.config.ts pointing to the schema and credentials is required.

Does Better Auth support Drizzle and Prisma adapters?

Yes, Better Auth provides ORM adapters imported from better-auth/adapters/drizzle, better-auth/adapters/prisma, and better-auth/adapters/mongodb. It also accepts direct connections like pg.Pool, postgres.js, and @neondatabase/serverless.

Why are my Better Auth sessions not stored in the database?

When secondaryStorage is defined, sessions go there by default instead of the database. Set session.storeSessionInDatabase to true to also persist them, or remove secondaryStorage to use the database directly.

What plugins does Better Auth support?

Better Auth offers plugins including twoFactor, organization, passkey, magicLink, emailOtp, username, phoneNumber, admin, apiKey, jwt, and sso. Import each from its dedicated path like better-auth/plugins/two-factor for tree-shaking, and re-run the CLI after adding plugins.