.env.example to .env in the root directory to get started.
Environment Files
ZeroStarter uses a type-safe environment validation system powered by@t3-oss/env-core in the @packages/env workspace.
Location: packages/env/
Validation: All environment variables are validated at build time and runtime
Server Variables
These variables configure the Hono API server (api/hono).
NODE_ENV
local, development, production
Usage: Determines the runtime environment and enables/disables certain features
HONO_APP_URL
https://api.example.com)
HONO_TRUSTED_ORIGINS
Rate Limiting
HONO_RATE_LIMIT
- Unauthenticated users: 60 requests per minute
- Authenticated users: 120 requests per minute (2x the limit)
HONO_RATE_LIMIT_WINDOW_MS
Authentication
BETTER_AUTH_SECRET
GitHub OAuth
- Go to GitHub Developer Settings
- Create a new OAuth App
- Set Authorization callback URL to:
{HONO_APP_URL}/api/auth/callback/github - Copy Client ID and generate a Client Secret
- Local:
http://localhost:4000/api/auth/callback/github - Production:
https://api.example.com/api/auth/callback/github
Google OAuth
- Go to Google Cloud Console
- Create a new OAuth 2.0 Client ID
- Add authorized redirect URI:
{HONO_APP_URL}/api/auth/callback/google - Copy Client ID and Client Secret
- Local:
http://localhost:4000/api/auth/callback/google - Production:
https://api.example.com/api/auth/callback/google
Database
POSTGRES_URL
- Neon - Serverless Postgres
- Supabase - Postgres with auth and storage
- Railway - Easy deployment platform
- Vercel Postgres - Integrated with Vercel
Client Variables
These variables configure the Next.js web application (web/next). All client variables must be prefixed with NEXT_PUBLIC_ to be exposed to the browser.
NEXT_PUBLIC_APP_URL
https://example.com)
NEXT_PUBLIC_API_URL
HONO_APP_URL)
Production: Set to your API domain (e.g., https://api.example.com)
Analytics (Optional)
PostHog Analytics
- Create a PostHog account
- Create a new project
- Copy the Project API Key
- Choose your region:
- US:
https://us.i.posthog.com - EU:
https://eu.i.posthog.com
- US:
User Feedback (Optional)
NEXT_PUBLIC_USERJOT_URL
Turbo Environment Variables
Turborepo automatically passes these environment variables to all workspaces. This is configured inturbo.json:
CI/CD Variables
SKIP_ENV_VALIDATION
Environment Variable Validation
ZeroStarter uses@t3-oss/env-core for type-safe environment variables. The validation schema is defined in packages/env/.
Benefits:
- Type-safe access to environment variables
- Runtime validation on startup
- Build-time validation
- Autocomplete in your IDE
- Prevents deployment with missing/invalid variables
Security Best Practices
- Never commit
.envfiles - They’re in.gitignoreby default - Rotate secrets regularly - Especially
BETTER_AUTH_SECRET - Use different secrets per environment - Don’t reuse development secrets in production
- Restrict OAuth redirect URIs - Only whitelist your actual domains
- Use HTTPS in production - All URLs should use
https:// - Limit CORS origins - Only allow trusted domains in
HONO_TRUSTED_ORIGINS - Keep
.env.exampleupdated - Document all required variables without exposing values
Troubleshooting
”Environment variable X is missing”
- Ensure
.envexists in the root directory - Check that the variable is defined in
.env - Rebuild
@packages/env:bun run build --filter=@packages/env - Restart your development server
OAuth callback errors
- Verify callback URLs match exactly (including protocol and port)
- Check that
HONO_APP_URLis correct - Ensure OAuth app is configured with the correct redirect URI
Database connection issues
- Verify
POSTGRES_URLformat is correct - Test connection:
bun run db:studio - Check database is running and accessible
- Ensure firewall allows connections (for remote databases)