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:

VariableDescriptionAuto-Generated
AUTH_SECRETAuthentication secret (32+ bytes)✅ Yes
DATABASE_URLPostgreSQL connection URL✅ Yes (with Docker)
CLICKHOUSE_HOSTClickHouse 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 32

OAuth Providers (Optional)

Without OAuth: Email authentication (magic links) works automatically.

With OAuth: Users can sign in with GitHub/Google.

VariableDescription
AUTH_GITHUB_IDGitHub OAuth app client ID
AUTH_GITHUB_SECRETGitHub OAuth app secret
AUTH_GOOGLE_IDGoogle OAuth app client ID
AUTH_GOOGLE_SECRETGoogle 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/database

Docker default:

postgresql://bklit:generated-password@localhost:5432/bklit

CLICKHOUSE_HOST (Required)

Purpose: ClickHouse connection for analytics events

Auto-configured: Yes (with Docker)

Default:

http://localhost:8123

Credentials:

  • 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.

VariableDescription
POLAR_ACCESS_TOKENPolar.sh API access token
POLAR_ORGANIZATION_IDYour Polar organization ID
POLAR_WEBHOOK_SECRETSecret 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).

VariableDescription
RESEND_API_KEYResend 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: 123456

Get API key: Resend Dashboard

External Services (Optional)

Maps - Mapbox

Without Mapbox: Geographic data shows as list view.

With Mapbox: Interactive map visualization.

VariableDescription
NEXT_PUBLIC_MAPBOX_TOKENMapbox 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.

VariableDescription
TRIGGER_SECRET_KEYTrigger.dev secret key
TRIGGER_API_KEYTrigger.dev API key
TRIGGER_API_URLTrigger.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 dev

Production Environment

Set NODE_ENV=production for:

  • Resend required for emails
  • Enhanced security
  • Optimized builds
  • Error tracking

Health Monitoring (Optional)

VariableDescription
HEALTH_CHECK_SECRETSecret for health check endpoints
ALERT_EMAILEmail for health check alerts

Auto-generated: HEALTH_CHECK_SECRET is auto-generated by wizard.

App Configuration

VariableDescriptionDefault
NODE_ENVEnvironment modedevelopment
NEXT_PUBLIC_APP_URLPublic app URLhttp://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 jobs

Quick Setup

Don't want to configure manually? Run:

npx @bklit/create

The wizard handles all of this automatically!

On this page