Authentication Setup
This starter kit uses Better-Auth for authentication. For advanced configurations and additional features, refer to the Better-Auth documentation.
Environment Variables
The following variables need to be configured in your .env.local
file for authentication:
General Settings
NEXT_PUBLIC_APP_URL
: Your application's public URL- Development:
localhost:3000
- Production:
https://your-domain.com
- Used for callbacks and public-facing URLs
- Development:
Authentication Settings
-
BETTER_AUTH_SECRET
: Secret key for encrypting sessions and tokens- Generate using:
- Online Generator
- Terminal:
openssl rand -base64 32
- ⚠️ Must be changed in production
- Keep this value private and never commit it
- Generate using:
-
BETTER_AUTH_URL
: Base URL for authentication callbacks- Development:
http://localhost:3000
- Production:
https://your-domain.com
- Must include protocol (http/https)
- Development:
OAuth Settings (Optional)
GITHUB_CLIENT_ID
: Your GitHub OAuth app client IDGITHUB_CLIENT_SECRET
: Your GitHub OAuth app secret- Both obtained from GitHub Developer Settings
- Required only if using GitHub authentication
Email Settings (Optional)
SMTP_HOST
: Your SMTP server hostnameSMTP_PORT
: SMTP port (usually 587 or 465)SMTP_SECURE
: Use TLS (true for 465, false for other ports)SMTP_USER
: SMTP account usernameSMTP_PASSWORD
: SMTP account passwordSMTP_FROM
: Sender email address- Required only for email/password authentication
- Used for verification and password reset emails
Important
Never commit sensitive credentials to version control. Use .env.local
for your secrets.
Next Steps
After configuring your environment variables, proceed to: