Environment packages
Environment configuration is centralized inpackages/env/ with three exports:
@better-skills/env/server- Server environment@better-skills/env/web- Web app environment@better-skills/env/cli- CLI environment
Environment variables are validated on startup. Missing or invalid variables will throw errors before the app runs.
Server environment
Required forapps/server/.
Location
Required variables
Variable descriptions
| Variable | Description | Example |
|---|---|---|
DATABASE_URL | PostgreSQL connection string | postgresql://user:pass@localhost:5432/db |
BETTER_AUTH_SECRET | Secret key for Better Auth (32+ chars) | your-32-character-secret-key-here |
BETTER_AUTH_URL | Base URL for auth callbacks | http://localhost:3000 |
CORS_ORIGIN | Allowed CORS origin (web app URL) | http://localhost:3001 |
GOOGLE_CLIENT_ID | Google OAuth client ID | From Google Cloud Console |
GOOGLE_CLIENT_SECRET | Google OAuth client secret | From Google Cloud Console |
GITHUB_CLIENT_ID | GitHub OAuth client ID | From GitHub OAuth Apps |
GITHUB_CLIENT_SECRET | GitHub OAuth client secret | From GitHub OAuth Apps |
NODE_ENV | Runtime environment | development, production, or test |
Web environment
Required forapps/web/.
Location
Next.js reads from
.env.local for local development. Use .env.production for production builds.Required variables
Variable descriptions
| Variable | Description | Example |
|---|---|---|
NEXT_PUBLIC_SERVER_URL | API server URL (exposed to browser) | http://localhost:3000 |
CLI environment
Required forapps/cli/.
Location
The CLI reads from:.envfile in current directory- Environment variables
- Default values
Variables
Variable descriptions
| Variable | Description | Default |
|---|---|---|
SERVER_URL | API server URL | http://localhost:3000 |
Production configuration
Server production
apps/server/.env
Web production
apps/web/.env.production
CLI production
For the installer script:Generating secrets
BETTER_AUTH_SECRET
Generate a secure 32+ character secret:OAuth setup
Google OAuth
Create OAuth credentials
Go to Google Cloud Console.
Create OAuth 2.0 Client ID
Choose “Web application” and set:
- Authorized redirect URIs:
http://localhost:3000/api/auth/callback/google
GitHub OAuth
Register OAuth app
Go to GitHub Developer Settings.
Create new OAuth App
Set:
- Homepage URL:
http://localhost:3001 - Authorization callback URL:
http://localhost:3000/api/auth/callback/github
Validation
All environment variables are validated at runtime. Invalid configuration will throw errors:Turbo configuration
Turborepo is aware of environment variables listed inturbo.json:
turbo.json
Troubleshooting
Environment variables not loading
Environment variables not loading
Ensure:
.envfiles are in the correct locations- Variable names match exactly (case-sensitive)
- No spaces around
=signs - No quotes needed for values
CORS errors in browser
CORS errors in browser
Verify:
CORS_ORIGINin server.envmatches your web app URLNEXT_PUBLIC_SERVER_URLin web.env.localmatches your server URL- Both services are running
OAuth not working
OAuth not working
Check:
- Client IDs and secrets are correct
- Redirect URIs match exactly (including protocol)
- OAuth app is not in development mode (for Google)
Next steps
Development Setup
Return to development setup guide
Database Setup
Configure your database connection