better-auth-best-practices

Configure Better Auth authentication and session management in TypeScript projects.

4|Updated Feb 12, 2026
One-click install
npx skills add https://github.com/rbaumier/skills --skill better-auth-best-practices-rbaumier
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-auth-best-practices
Source: https://github.com/rbaumier/skills/tree/main/better-auth-best-practices
Command: npx skills add https://github.com/rbaumier/skills --skill better-auth-best-practices-rbaumier

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide reduces integration errors and security misconfigurations when adding Better Auth to TypeScript projects by providing clear, operational guidance for authentication, sessions, plugins, adapters, client integration, and middleware.

Core Features & Use Cases

  • Environment and config guidance: Use env-driven secrets and base URLs, and know when to supply config fallbacks.
  • Adapter and schema rules: Correct ORM model naming, Drizzle pluralization and field mappings, and migration best practices to avoid silent failures.
  • Session, client, and middleware patterns: Recommendations for secondary storage, session persistence, cookie strategies, client plugins and global error handlers, and safe middleware header forwarding.
  • Plugin and security patterns: How to enable two-factor, organization, passkeys, and trusted provider rules, plus rate limiting and CSRF-safe defaults.
  • Use case: Integrating Better Auth into a full-stack TypeScript app with Prisma/Drizzle, Next.js middleware, and an Expo mobile client.

Quick Start

Use this guide to configure Better Auth with env-driven secrets and base URLs, correct ORM model names and Drizzle options, session persistence when using Redis, matching client-side plugins and onAPIError handlers, and safe middleware header forwarding.

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 Drizzle ORM to avoid silent migration failures?

Configuring Better Auth with Drizzle requires correct ORM model naming, proper Drizzle pluralization and field mappings, and disciplined migration practices to prevent silent schema failures and ensure database synchronization.

What's the best way to manage session persistence with Better Auth using Redis?

The best way to manage Better Auth session persistence with Redis is to implement secondary storage, which handles session persistence and cookie strategies to maintain secure, continuous user sessions across server and client environments.

Does Better Auth support two-factor authentication and passkeys in TypeScript apps?

Better Auth supports two-factor authentication, passkeys, organization management, and OAuth provider rules in TypeScript apps, utilizing specific plugin patterns to enable these security features across server, client, and middleware setups.

How do I safely forward headers in Next.js middleware for Better Auth?

To safely forward headers in Next.js middleware for Better Auth, apply safe middleware header forwarding patterns that securely transmit authentication data between server, client, and mobile setups without exposing sensitive session information.

Can I use Better Auth with Prisma and Expo in a full-stack TypeScript app?

You can integrate Better Auth with Prisma and Expo across a full-stack TypeScript app, using adapter schema rules for Prisma, matching client-side plugins, global onAPIError handlers, and secure mobile client configurations.

Why does Better Auth require environment-driven secrets and base URLs?

Better Auth requires environment-driven secrets and base URLs to satisfy operational security requirements, ensuring authentication processes use safe fallback configurations and preventing hardcoded sensitive data exposure across server environments.