better-auth

v2026.09.24

Better Auth in TypeScript — setting up the auth instance, picking adapters, wiring framework route handlers, configuring sessions and cookies, adding plugins (2FA, organization, admin, magicLink, JWT), or porting from NextAuth/Auth.js, Clerk, Auth0, or Supabase Auth. Covers Next.js, SvelteKit, Hono, Express, Nuxt, Astro, and React/Vue/Svelte clients. Trigger when writing, reviewing, or migrating Better Auth code — and even when the user doesn't explicitly mention Better Auth but is working on TypeScript authentication, session cookies, OAuth providers, or auth-library migration. Contains 42 rules organized by impact across 8 categories.

GitHub
Install command
npx skhub add pproenca/better-auth
Markdown
SKILL.md

Better Auth Best Practices

Implementation and migration guide for Better Auth, the framework-agnostic TypeScript authentication and authorization library. This skill contains 42 rules organized by impact across 8 categories, derived from the official documentation and migration guides.

When to Apply

Reference these guidelines when:

  • Setting up a fresh Better Auth instance (config, adapter, route handler, client)
  • Wiring framework-specific integrations (Next.js App/Pages Router, SvelteKit, Hono, Express, Nuxt, Astro)
  • Configuring sessions, cookies, and security (rate limit, trusted origins, password hashing)
  • Adding plugins: 2FA, organization, admin, magicLink, JWT, passkey, multi-session
  • Migrating from another auth library (NextAuth/Auth.js, Clerk, Auth0, Supabase Auth)
  • Debugging "session is null" / "redirect_uri_mismatch" / 403 CSRF errors
  • Reviewing PRs that touch lib/auth.ts, auth-client.ts, or /api/auth/ route handlers

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Setup & ConfigurationCRITICALsetup-
2Database Adapters & SchemaCRITICALdb-
3API Route HandlersCRITICALroute-
4Session & CookiesHIGHsession-
5Auth Methods & ProvidersHIGHauth-
6Security & HardeningHIGHsecurity-
7Plugins & ExtensionsMEDIUMplugins-
8Migration from Other AuthMEDIUMmigrate-

Quick Reference

1. Setup & Configuration (CRITICAL)

2. Database Adapters & Schema (CRITICAL)

3. API Route Handlers (CRITICAL)

4. Session & Cookies (HIGH)

5. Auth Methods & Providers (HIGH)

6. Security & Hardening (HIGH)

7. Plugins & Extensions (MEDIUM)

8. Migration from Other Auth (MEDIUM)

How to Use

For a fresh implementation, read in priority order: start with all setup- rules, then db-, then route- — these CRITICAL categories must be correct or nothing else works. After the foundation, pick the rules that match your scope: session- for cookie/expiry tuning, auth- for provider configuration, security- for production hardening.

For a migration from another auth library, read migrate-parallel-cutover first (strategy), then security-password-hash-interop (preserve user passwords), then migrate-oauth-account-mapping and migrate-nextauth-schema-mapping (data layout).

Read individual reference files for detailed explanations, incorrect vs. correct code examples, and links to the canonical Better Auth documentation.

Reference Files

FileDescription
references/_sections.mdCategory definitions ordered by impact
assets/templates/_template.mdTemplate for adding new rules
metadata.jsonVersion, references, and discipline metadata
Discovery
Tags

No tags published for this skill.

Version
Latest version metadata

Version

v2026.09.24

Published

Sep 24, 2026

Category

Uncategorized

License

MIT

Source path

skills/.experimental/better-auth

Default branch

master

Latest commit

cf93c57

Tree SHA

afbb575