Required variables
These environment variables must be set for the application to run.Database configuration
The
TURSO_DATABASE_URL is required. The TURSO_AUTH_TOKEN is optional for local development but required for production.Authentication configuration
AUTH_SECRET is used by NextAuth.js to encrypt session tokens and sign cookies. Generate a secure random string for production.
Generate a secret:
Google OAuth (optional)
If you want to enable Google authentication, configure these variables:Environment files
The application supports different environment files for various deployment stages:.env.local- Local development (used by default withnpm run dev).env.production- Production deployment
Environment files are gitignored by default. Never commit them to your repository.
Example configuration
Create a.env.local file in your project root:
.env.local
Loading environment variables
Next.js automatically loads environment variables from.env.local during development. For production, configure environment variables in your hosting platform.
Migration scripts
The database migration scripts explicitly load environment files:package.json:10-11, scripts/migrate.mjs:14-22
Security best practices
- Never commit secrets - Add
.env*to.gitignore - Use strong secrets - Generate cryptographically secure random values
- Rotate credentials - Regularly update secrets and tokens
- Limit access - Only give environment variables to services that need them
- Use different secrets - Never reuse secrets across environments
Troubleshooting
Missing environment variables
If you see errors about missing environment variables:- Verify the variable is set in your
.env.localfile - Check for typos in the variable name
- Restart your development server after changing environment files
Database connection failures
If the database connection fails:- Verify
TURSO_DATABASE_URLis correct - Check that
TURSO_AUTH_TOKENis valid and not expired - Ensure your database instance is running
Authentication errors
If authentication fails:- Verify
AUTH_SECRETis set - For Google OAuth, check that both
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETare correct - Ensure OAuth redirect URIs are configured in Google Cloud Console