better-auth-best-practices

Integrate Better Auth authentication into TypeScript applications with SQLite, Prisma, or Drizzle.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill documents how to correctly integrate Better Auth into TypeScript applications, removing guesswork around configuration, session management, plugin usage, and production security so teams can ship reliable authentication without costly mistakes.

Core Features & Use Cases

  • Config & Environment: Explains required environment variables, config locations, and how to supply secrets and base URLs safely.
  • Session & Storage Strategies: Covers cookie cache strategies, secondary storage for sessions, and options for stateless vs persisted sessions.
  • Adapters, Plugins & Hooks: Describes adapter choices for Drizzle/Prisma/SQLite, plugin import patterns, and endpoint/database hooks for customization.
  • Security & Best Practices: Highlights secure cookie settings, CSRF/origin handling, rate limiting, and migration/CLI reminders for production readiness.
  • Use Case: Integrate email/password plus Google OAuth with a Drizzle adapter, store sessions in Redis for scale, and add two-factor and passkey plugins while enforcing secure cookies.

Quick Start

Install and configure Better Auth by setting BETTER_AUTH_SECRET and BETTER_AUTH_URL and adding an auth.ts configuration with the chosen database adapter, session strategy, and required plugins.

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 configure Better Auth with a Drizzle adapter and Google OAuth in TypeScript?

To configure Better Auth with Drizzle and Google OAuth in TypeScript, set BETTER_AUTH_SECRET and BETTER_AUTH_URL environment variables, then define your auth.ts file using the Drizzle database adapter and include the Google OAuth provider plugin.

What environment variables are required for Better Auth production setup?

Better Auth production setup requires the BETTER_AUTH_SECRET environment variable for securing sessions and tokens, and BETTER_AUTH_URL to define the application's base URL for callback routing and origin validation.

Can I use Redis for secondary storage to persist Better Auth sessions?

Yes, Better Auth supports secondary storage like Redis to persist sessions for scalability. Configuring secondary storage allows Better Auth to externalize session state, enabling better rate limiting and stateless session management.

How does Better Auth handle CSRF protection and secure cookies?

Better Auth handles CSRF protection and secure cookies by enforcing origin validation and applying secure cookie settings automatically. These production security measures prevent cross-site request forgery and unauthorized session access.

What TypeScript databases and plugins work with Better Auth authentication?

Better Auth authentication works with SQLite, Prisma, and Drizzle database adapters in TypeScript applications. Supported plugins include two-factor authentication, passkeys, magic links, and OAuth providers for extensible auth workflows.

When should I use stateless versus persisted sessions in Better Auth?

Use stateless sessions in Better Auth for simpler, cookie-cached setups without external dependencies, and use persisted sessions with secondary storage like Redis when you need scalable session management and distributed rate limiting.