This library is in early development. Expect breaking changes.
Core Concepts

serverAuth()

When to reach for the full Better Auth server instance.

serverAuth(event?) returns the Better Auth instance (module-level singleton). Pass the event for accurate URL detection on first initialization. Prefer the helper utilities for common checks, and reach for serverAuth() when you need the full Better Auth API or plugin-specific endpoints.

When to Use What

TaskUseExample
Get current sessiongetUserSession(event)Check if user is logged in
Require authenticationrequireUserSession(event)Protect an API route
Access Better Auth APIserverAuth(event)Call auth.api.listSessions()
Get session with optionsrequireUserSession(event, { role: 'admin' })Role-based protection