better-auth-best-practices

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

Updated May 26, 2026
One-click install
npx skills add https://github.com/Albo-Club/albo-os --skill better-auth-best-practices-albo-club
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-auth-best-practices
Source: https://github.com/Albo-Club/albo-os/tree/main/.agents/skills/better-auth-best-practices
Command: npx skills add https://github.com/Albo-Club/albo-os --skill better-auth-best-practices-albo-club

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—database adapters, session storage, plugins, and CLI migrations—and misconfigurations cause subtle bugs. This Skill provides a structured reference so you configure Better Auth correctly the first time. ## Core Features & Use Cases - Setup Workflow: Step-by-step installation, environment variables, auth.ts creation, route handlers, and CLI migrations for built-in, Drizzle, and Prisma adapters. - Configuration Reference: Covers core options, session management (cookie cache strategies, secondary storage), email flows, security settings, hooks, and plugins like twoFactor, organization, and magicLink. - Use Case: You are adding email/password plus Google OAuth to a TanStack Start app with a Drizzle/Postgres backend. Use this Skill to generate the schema, configure social providers, set up session cookie caching, and avoid the model-name vs table-name pitfall. ## Quick Start Use the better-auth-best-practices skill to set up Better Auth with email/password and the organization plugin in my TypeScript project.

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 email and password?

Install better-auth, set BETTER_AUTH_SECRET and BETTER_AUTH_URL environment variables, create an auth.ts with a database adapter, and enable emailAndPassword in the config. Run npx @better-auth/cli@latest migrate to apply the schema, then verify with GET /api/auth/ok.

How to run Better Auth migrations with Drizzle or Prisma?

For Drizzle, run npx @better-auth/cli@latest generate --output src/db/auth-schema.ts, then drizzle-kit push or migrate. For Prisma, generate into prisma/schema.prisma and run npx prisma migrate dev. Re-run the CLI after adding or changing plugins.

Does Better Auth support OAuth providers like Google?

Yes, configure socialProviders in auth.ts with each provider's clientId and clientSecret, such as google: { clientId, clientSecret }. Enable account.storeAccountCookie if you need stateless OAuth account linking.

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".

Where are Better Auth sessions stored by default?

If secondaryStorage like Redis is defined, sessions go there instead of the database. Set session.storeSessionInDatabase to true to also persist to the DB, or use cookieCache for fully stateless sessions without a database.