Introducing a new way to review your PRs.

Read the announcement

better-auth / better-auth

The most comprehensive authentication framework

View on GitHub

24 documents · Updated Nov 23, 2026

overview

Knowledge Base updated: 2026-11-22

Better Auth knowledge base

Better Auth is a TypeScript monorepo centered on the @better-auth/core primitives and the better-auth server package. Optional packages extend those foundations with plugins, protocol support, persistence adapters, runtime integrations, and operational tooling.

Critical authentication state is coordinated in server routes and database adapters: users, accounts, sessions, verification records, and secondary storage are handled through the main package's internal adapter and persistence boundaries. Request-scoped context and transaction handling live in the core package.

Use this index to route changes to the page that owns the affected package or subsystem. Overview pages explain boundaries; child pages describe focused implementation areas.

flowchart TD
  App[Application] --> Client[Client SDK and framework integrations]
  Client --> Server[better-auth server package]
  Server --> Core[@better-auth/core]
  Server --> Plugins[Plugin system]
  Server --> Sessions[Sessions and account lifecycle]
  Core --> Context[Request context and endpoints]
  Server --> DB[Database adapter ecosystem]
  Server --> Storage[Redis storage]
  Plugins --> Identity[API keys and passkeys]
  Plugins --> Enterprise[OAuth provider / SSO / SCIM]
  Server --> Social[OAuth and social providers]
  Server --> Billing[Stripe integration]
  CLI[CLI and release tooling] --> Server
  Native[Expo and Electron] --> Client
  I18N[i18n locales] --> Server

Glossary

  • Internal adapter: the main package abstraction that performs authentication persistence operations and coordinates adapter behavior.
  • Secondary storage: non-primary persistence used by authentication flows, such as cached or externally stored state.
  • CIMD: Client ID Metadata Document validation, resolution, and storage support.
  • Device authorization: an OAuth-style flow implemented as an optional authentication plugin capability.
  • SCIM: enterprise identity provisioning interoperability provided by the SCIM package.

Codebase-wide invariants

  • Request-scoped transaction behavior must preserve context propagation; see packages/…/transaction.ts.
  • Authentication persistence flows go through internal adapter boundaries rather than directly coupling routes to a database implementation; see packages/…/internal-adapter.ts.
  • Session API behavior must remain consistent with session route handling and its coverage; see packages/…/session.ts and session-api.test.ts.
  • Authentication error identifiers are centrally defined for consistent server and client handling; see packages/…/codes.ts.
  • Optional features are composed through package/plugin boundaries, not folded into every base deployment; see packages/better-auth/src/plugins/**.

Routing table

Path or triggerDocumentation
packages/core/src/**, packages/…/index.ts, packages/…/package.jsonAuthentication engine
packages/core/src/context/**, packages/core/src/api/**, packages/core/src/error/**, packages/core/src/env/**, packages/core/src/utils/**Core API and request lifecycle
packages/better-auth/src/api/**, packages/better-auth/src/db/**, packages/better-auth/src/crypto/**, packages/better-auth/src/cookies/**Server authentication and sessions
packages/better-auth/src/client/**, packages/better-auth/src/integrations/**, packages/better-auth/src/react/**, packages/better-auth/src/vue/**Client SDK and framework integrations
packages/core/src/oauth2/**, packages/better-auth/src/api/routes/oauth2/**, packages/better-auth/src/social-providers/**OAuth and social sign-in
packages/api-key/**, packages/passkey/**, packages/cimd/**, packages/i18n/**, packages/oauth-provider/**, packages/sso/**, packages/scim/**Extensibility and identity platform
packages/better-auth/src/plugins/**Plugin system and authentication features
packages/api-key/**API key management
packages/passkey/**Passkey authentication
packages/cimd/**Client ID metadata documents
packages/i18n/**Internationalization support
packages/oauth-provider/**, packages/sso/**, packages/scim/**Enterprise identity protocols
packages/drizzle-adapter/**, packages/prisma-adapter/**, packages/kysely-adapter/**, packages/mongo-adapter/**, packages/memory-adapter/**, packages/redis-storage/**, packages/expo/**, packages/electron/**Data and runtime adapters
packages/drizzle-adapter/**, packages/prisma-adapter/**, packages/kysely-adapter/**, packages/mongo-adapter/**, packages/memory-adapter/**Database adapter ecosystem
packages/redis-storage/**Distributed storage and caching
packages/expo/**, packages/electron/**, demos/expo/**, demos/electron/**Mobile and desktop runtimes
packages/stripe/**, packages/telemetry/**, packages/mcp/**Commercial and operational integrations
packages/stripe/**Stripe billing integration
packages/telemetry/**, packages/better-auth/src/telemetry/**Telemetry and instrumentation
packages/mcp/**Model Context Protocol integration
packages/cli/**, packages/release-tooling/**, .github/workflows/**Developer tooling and release automation
packages/cli/**CLI setup and migration workflows
packages/release-tooling/**, .github/…/backport.yml, .github/…/claude.yml, .github/…/sync-version-docs.ymlRelease tooling automation