better-auth-best-practices

Configures Better Auth authentication for TypeScript applications with plugins, sessions, and database adapters.

1|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/dominionism/Noesis --skill better-auth-best-practices-dominionism
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: better-auth-best-practices
Source: https://github.com/dominionism/Noesis/tree/main/assets/skills/better-auth-best-practices
Command: npx skills add https://github.com/dominionism/Noesis --skill better-auth-best-practices-dominionism

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Integrating authentication into a TypeScript application involves many configuration decisions—session storage, cookie strategies, database adapters, plugins, and security settings—where small mistakes cause broken logins or security gaps. This Skill provides a consolidated reference of Better Auth configuration patterns and common pitfalls so agents generate correct auth setups. ## Core Features & Use Cases - Configuration Reference: Covers core options like baseURL, secret, database adapters (Drizzle, Prisma, MongoDB, direct SQL pools), and trusted origins. - Session & Security Guidance: Explains cookie cache strategies (compact, JWT, JWE), secondary storage, rate limiting, CSRF, and secure cookie settings. - Plugin & Client Setup: Documents tree-shakable plugin imports (twoFactor, organization, passkey, magicLink, etc.) and framework clients for React, Vue, Svelte, and Solid. - Use Case: When adding email/password plus Google OAuth login to a Next.js app with a Prisma database, use this Skill to generate the auth.ts config, run the CLI schema generation, and avoid the model-name vs table-name pitfall. ## Quick Start Set up Better Auth with email and password sign-in plus Google OAuth using a Prisma adapter 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 in a TypeScript project?▼

Create an auth.ts file exporting a betterAuth instance with your database connection, emailAndPassword enabled, and any social providers. Set BETTER_AUTH_SECRET and BETTER_AUTH_URL environment variables, then run the CLI migrate or generate command to create the schema.

How do I add plugins like two-factor or passkey 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 config. Re-run the CLI after adding plugins so the database schema includes the new tables and fields.

Does Better Auth work with Prisma and Drizzle ORMs?▼

Yes, Better Auth provides adapters imported from better-auth/adapters/prisma, better-auth/adapters/drizzle, 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 like Redis 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 secondaryStorage.

Can Better Auth run without a database?▼

Yes, with no database configured and cookieCache enabled, Better Auth runs in fully stateless mode where the session lives only in a signed or encrypted cookie. Logout then depends on cookie cache expiry rather than server-side revocation.