Environment Variables
Complete reference for required and optional configuration
Environment Variables
This guide explains every environment variable in Bklit, what's required, and what's optional.
Quick Reference
Required (3 variables)
These are auto-generated by npx @bklit/create:
| Variable | Description | Auto-Generated |
|---|---|---|
AUTH_SECRET | Authentication secret (32+ bytes) | ✅ Yes |
DATABASE_URL | PostgreSQL connection URL | ✅ Yes (with Docker) |
CLICKHOUSE_HOST | ClickHouse server URL | ✅ Yes (with Docker) |
Optional (Everything Else)
All other variables enable optional features. Core analytics work without them.
Authentication
AUTH_SECRET (Required)
Purpose: Encrypts sessions and tokens
Auto-generated: Yes (32-byte random secret)
Manual generation:
openssl rand -base64 32OAuth Providers (Optional)
Without OAuth: Email authentication (magic links) works automatically.
With OAuth: Users can sign in with GitHub/Google.
| Variable | Description |
|---|---|
AUTH_GITHUB_ID | GitHub OAuth app client ID |
AUTH_GITHUB_SECRET | GitHub OAuth app secret |
AUTH_GOOGLE_ID | Google OAuth app client ID |
AUTH_GOOGLE_SECRET | Google OAuth app secret |
Databases
DATABASE_URL (Required)
Purpose: PostgreSQL connection for user data, projects, organizations
Auto-configured: Yes (with Docker)
Format:
postgresql://user:password@host:port/databaseDocker default:
postgresql://bklit:generated-password@localhost:5432/bklitCLICKHOUSE_HOST (Required)
Purpose: ClickHouse connection for analytics events
Auto-configured: Yes (with Docker)
Default:
http://localhost:8123Credentials:
- Username:
default - Password: (empty for local Docker)
Billing (Optional)
Without Polar: All users have free tier access. Billing features hidden.
With Polar: Enable paid subscription plans.
| Variable | Description |
|---|---|
POLAR_ACCESS_TOKEN | Polar.sh API access token |
POLAR_ORGANIZATION_ID | Your Polar organization ID |
POLAR_WEBHOOK_SECRET | Secret for webhook verification |
POLAR_SERVER_MODE | "sandbox" or "production" |
Get credentials: Polar.sh Dashboard
Setup guide: Polar Setup
Email (Optional)
Without Resend: Emails log to console in development. Production requires Resend.
With Resend: Send transactional emails (welcome, password reset, invitations).
| Variable | Description |
|---|---|
RESEND_API_KEY | Resend API key for sending emails |
Development behavior:
# Email appears in terminal instead of being sent
📧 EMAIL (Development - Console Mode)
📬 To: [email protected]
📋 Subject: Verify your Bklit email
🔑 OTP: 123456Get API key: Resend Dashboard
External Services (Optional)
Maps - Mapbox
Without Mapbox: Geographic data shows as list view.
With Mapbox: Interactive map visualization.
| Variable | Description |
|---|---|
NEXT_PUBLIC_MAPBOX_TOKEN | Mapbox public access token |
Get token: Mapbox (free tier available)
Background Jobs - Trigger.dev
Without Trigger.dev: Health checks and scheduled tasks disabled.
With Trigger.dev: Enable background jobs and monitoring.
| Variable | Description |
|---|---|
TRIGGER_SECRET_KEY | Trigger.dev secret key |
TRIGGER_API_KEY | Trigger.dev API key |
TRIGGER_API_URL | Trigger.dev API URL |
Get credentials: Trigger.dev
Development vs Production
Development Environment
Set NODE_ENV=development to enable:
- OTP codes in terminal (no email needed)
- Email console logging
- Detailed error messages
- Hot reloading
Additional dev variables:
DEV_DATABASE_URL="..." # Overrides DATABASE_URL in dev
DEV_CLICKHOUSE_HOST="..." # Overrides CLICKHOUSE_HOST in devProduction Environment
Set NODE_ENV=production for:
- Resend required for emails
- Enhanced security
- Optimized builds
- Error tracking
Health Monitoring (Optional)
| Variable | Description |
|---|---|
HEALTH_CHECK_SECRET | Secret for health check endpoints |
ALERT_EMAIL | Email for health check alerts |
Auto-generated: HEALTH_CHECK_SECRET is auto-generated by wizard.
App Configuration
| Variable | Description | Default |
|---|---|---|
NODE_ENV | Environment mode | development |
NEXT_PUBLIC_APP_URL | Public app URL | http://localhost:3000 |
Summary: What You Actually Need
For local development:
# These 3 are auto-generated by npx @bklit/create
AUTH_SECRET="..."
DATABASE_URL="postgresql://..."
CLICKHOUSE_HOST="http://localhost:8123"
# That's it! Everything else is optional.For production:
# Required
AUTH_SECRET="..."
DATABASE_URL="postgresql://..."
CLICKHOUSE_HOST="https://..."
RESEND_API_KEY="..." # Required in production for emails
# Recommended
AUTH_GITHUB_ID="..." # For OAuth
POLAR_ACCESS_TOKEN="..." # For billing
NEXT_PUBLIC_MAPBOX_TOKEN="..." # For maps
# Optional
TRIGGER_SECRET_KEY="..." # For background jobsQuick Setup
Don't want to configure manually? Run:
npx @bklit/createThe wizard handles all of this automatically!