better-auth-best-practices

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

Updated May 5, 2026
One-click install
npx skills add https://github.com/Rocktown-Labs/reluxury --skill better-auth-best-practices-rocktown-labs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-auth-best-practices
Source: https://github.com/Rocktown-Labs/reluxury/tree/main/.agents/skills/better-auth-best-practices
Command: npx skills add https://github.com/Rocktown-Labs/reluxury --skill better-auth-best-practices-rocktown-labs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Setting up TypeScript authentication with Better Auth involves many moving parts—environment variables, database adapters, session storage, plugins, and framework-specific clients—and misconfiguration leads to broken sessions, schema mismatches, or security gaps. ## Core Features & Use Cases - Server & Client Setup: Guides installation, auth.ts creation, route handlers, and framework-specific client imports for React, Vue, Svelte, and Solid. - Database & Session Management: Covers Drizzle, Prisma, MongoDB, and direct SQL adapters, plus session storage strategies including secondary storage, cookie caching, and stateless mode. - Plugins & Security: Documents plugin imports for two-factor, organization, passkey, and OAuth, along with rate limiting, CSRF, and secure cookie configuration. - Use Case: When adding email/password and Google OAuth login to a TanStack Start app with a Drizzle database, use this Skill to generate the correct auth.ts config, run the CLI migration, and wire up the client. ## Quick Start Set up Better Auth in my TypeScript app with email and password sign-in, a Drizzle database adapter, and session management.

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 environment variables, then create an auth.ts file passing a database connection or ORM adapter. Run npx @better-auth/cli@latest migrate to apply the schema, and verify with GET /api/auth/ok.

How do I add plugins to Better Auth?

Import plugins from dedicated paths like better-auth/plugins/two-factor for tree-shaking, then add them to the plugins array in your auth config. Re-run the CLI migrate or generate command afterward so plugin schema changes are applied.

Does Better Auth work with Drizzle and Prisma?

Yes, Better Auth provides ORM adapters imported from better-auth/adapters/drizzle, better-auth/adapters/prisma, and better-auth/adapters/mongodb. Note that config uses the ORM model name, not the underlying database table name.

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 sessions to the database, or remove secondary storage to use the database directly.

Can Better Auth run without a database?

Yes, Better Auth supports a fully stateless mode where sessions live only in the cookie cache using compact, jwt, or jwe strategies. Without a database, logout effectively happens on cookie cache expiry, and custom session fields are always re-fetched.