Authentication
Learn how to use our comprehensive authentication system powered by Better Auth.
Better Auth Overview
Modern Authentication Framework
Better Auth provides a complete authentication solution with support for multiple providers
Key Features
- • Multiple authentication providers
- • Session management
- • Two-factor authentication
- • Password reset & email verification
- • Organization/team management
- • Passkeys (WebAuthn)
Security Features
- • Rate limiting built-in
- • CSRF protection
- • Secure session cookies
- • OAuth state management
- • Email verification flows
- • Multi-session support
Email & Password Authentication
Traditional Authentication
Email and password authentication with security best practices
Features
Secure
Bcrypt password hashingVerification
Email verification requiredReset
Password reset flowsEmail Configuration
Configure email delivery using Resend:
RESEND_API_KEY - Your Resend API keyBETTER_AUTH_EMAIL - Sender email addressTwo-Factor Authentication
Enhanced Security
Protect accounts with two-factor authentication using email OTP
How It Works
- 1. User enables 2FA in their security settings
- 2. During login, user enters email and password
- 3. System sends OTP code to user's email
- 4. User enters OTP to complete authentication
Implementation
2FA is automatically configured when you set up email delivery. Users can enable/disable it from their security settings.
Session Management
Secure Sessions
Manage user sessions with security and flexibility
Session Features
Secure
HTTP-only cookiesMulti-session
Support multiple active sessionsRevocation
Revoke specific sessionsAccessing Sessions
Server Components:
auth.api.getSession(headers)Client Components:
useSession() hook
Social Providers
Supported OAuth Providers
Configure social login providers for seamless user authentication
Google OAuth
Enable Google authentication with just a few environment variables.
GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRET