Auth Providers
Configure authentication providers for your app.
Email + Password
Enabled by default. Users register with email, name, and password.
Email Verification
Email verification is required by default. Configure in lib/auth.ts:
emailAndPassword: {
enabled: true,
requireEmailVerification: true,
}Password Reset
The password reset flow:
- User requests reset at
/forgot-password - System generates a token (stored in
passwordResetTokentable, expires in 1 hour) - Reset email is sent with a link
- User sets new password at
/reset-password?token=...
Google OAuth
Google login is optional. The starter only enables the provider when both AUTH_GOOGLE_ID and AUTH_GOOGLE_SECRET are configured.
Setup
- Create OAuth credentials at Google Cloud Console
- Set authorized redirect URI to:
{YOUR_URL}/api/auth/callback/google - Add to
.env:
AUTH_GOOGLE_ID="your-client-id"
AUTH_GOOGLE_SECRET="your-client-secret"Adding More Providers
Better Auth supports many OAuth providers. To add GitHub, for example:
- Install the provider (if needed)
- Add to
socialProvidersinlib/auth.ts:
socialProviders: {
google: { ... },
github: {
clientId: process.env.AUTH_GITHUB_ID!,
clientSecret: process.env.AUTH_GITHUB_SECRET!,
},
}- Add the login button in
features/auth/components/