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.
| Task | Use | Example |
|---|---|---|
| Get current session | getUserSession(event) | Check if user is logged in |
| Require authentication | requireUserSession(event) | Protect an API route |
| Access Better Auth API | serverAuth(event) | Call auth.api.listSessions() |
| Get session with options | requireUserSession(event, { role: 'admin' }) | Role-based protection |