Overview
Featul uses better-auth for authentication with support for:- Email/password authentication with verification
- Google OAuth
- GitHub OAuth
- Passkeys (WebAuthn)
- Two-factor authentication (2FA)
- Multi-session support
OAuth Providers
Google OAuth
To enable Google authentication:- Go to Google Cloud Console
- Create a new project or select an existing one
- Navigate to APIs & Services > Credentials
- Create OAuth 2.0 Client ID
- Add authorized redirect URIs:
https://yourdomain.com/api/auth/callback/googlehttp://localhost:3000/api/auth/callback/google(for development)
Make sure to enable the Google+ API in your Google Cloud project.
.env
packages/auth/src/auth.ts:180-184
GitHub OAuth
To enable GitHub authentication:- Go to GitHub Developer Settings
- Click “New OAuth App”
- Set the authorization callback URL:
https://yourdomain.com/api/auth/callback/githubhttp://localhost:3000/api/auth/callback/github(for development)
.env
packages/auth/src/auth.ts:185-189
Email Verification
Email verification is required by default for email/password sign-ups:packages/auth/src/auth.ts:167-177
Email verification requires configuring the email service. See the Email Configuration page.
Better Auth Secret
Generate a secure random secret for session encryption:Cross-Subdomain Authentication
Featul supports multi-tenant subdomain routing with shared authentication:.env
NEXT_PUBLIC_APP_URL: Your main application URLAUTH_COOKIE_DOMAIN: Root domain for cross-subdomain cookies (e.g.,.featul.com)AUTH_TRUSTED_ORIGINS: Comma-separated list of trusted origins for CORS
packages/auth/src/auth.ts:16-36,193-206
For localhost development, leave
AUTH_COOKIE_DOMAIN empty or set it to localhost.Passkeys (WebAuthn)
Configure passkey authentication for passwordless login:.env
.env
PASSKEY_RP_ID: Relying Party ID (your domain)PASSKEY_RP_NAME: Display name for the passkeyPASSKEY_ORIGIN: Full origin URL of your application
packages/auth/src/auth.ts:238-242
Rate Limiting
Authentication endpoints are rate-limited to prevent abuse. Rate limiting requires Redis:.env
- Sign-in/Sign-up: 5 requests per 60 seconds
- Password reset: 3 requests per 5 minutes
- OTP verification: 5 requests per 60 seconds
packages/auth/src/auth.ts:210-227
Get free Redis hosting at Upstash.
Session Configuration
Sessions are configured with:- Secure cookies in production
- SameSite=None for cross-origin support
- HTTP-only cookies
- Multi-session support (multiple devices)
packages/auth/src/auth.ts:192-206