Environment Variables

All environment variables are declared in bun-env.d.ts for type-safe access via Bun.env. Copy .env.example to .env and fill in the required values before running the server.

Bun loads .env automatically — dotenv is not used.

Never commit .env to source control.


Required Variables

The server calls validateEnv() at startup and exits immediately if any of these are missing.

VariableTypeUsed byPurpose
POSTGRES_SERVERstringbackend/db/client.tsPostgreSQL hostname (e.g. localhost)
POSTGRES_DBstringbackend/db/client.tsDatabase name
POSTGRES_USERstringbackend/db/client.tsDatabase username
POSTGRES_PASSWORDstringbackend/db/client.tsDatabase password
JWT_SECRETstringbackend/utils/auth/HMAC-SHA256 secret for signing/verifying JWTs
APP_URLstringbackend/services/authService.tsBase URL used in invite links (e.g. https://example.com)

Optional Variables

These are safe to omit; the related feature is disabled or uses a sensible default.

Server

VariableDefaultUsed byPurpose
NODE_ENVbackend/server.tsproduction enables prod SPA serving; else dev mode
PORT3210backend/server.tsHTTP listen port
CORS_ORIGINbackend/utils/cors.tsComma-separated allowed origins, or *
DISABLE_RATE_LIMITbackend/middleware/rateLimitMiddleware.tsSet to "true" to bypass rate limiting (E2E tests)

Seed

VariableDefaultUsed byPurpose
SEED_ADMIN_EMAILbackend/db/seed.tsEmail address of the seeded admin user
SEED_ADMIN_PASSWORDbackend/db/seed.tsPassword for the seeded admin user
SEED_ADMIN_NAMEbackend/db/seed.tsDisplay name of the seeded admin user

E2E Tests

VariableDefault (baked in)Used byPurpose
E2E_TEST_EMAILe2e/global-setup.tsTest user email for Playwright runs
E2E_TEST_PASSWORDe2e/global-setup.tsTest user password for Playwright runs
E2E_TEST_NAMEe2e/global-setup.tsTest user display name

OpenTelemetry (opt-in)

Feature is disabled when OTEL_ENDPOINT is absent. See backend/features/telemetry/README.md.

VariableDefaultUsed byPurpose
OTEL_ENDPOINTbackend/features/telemetry/OTLP HTTP base URL; absence disables all backend OTel
OTEL_SERVICE_NAMEbun-boilerbackend/features/telemetry/Service name in all backend signals
BUN_PUBLIC_OTEL_SERVICE_NAMEfrontend/telemetry/telemetry.tsService name for browser spans; absence disables frontend OTel

SMTP Email (opt-in)

Feature is disabled when SMTP_HOST is absent. See backend/features/mail/README.md.

VariableDefaultUsed byPurpose
SMTP_HOSTbackend/features/mail/SMTP hostname; absence disables all email sending
SMTP_PORT587backend/features/mail/SMTP port
SMTP_USERbackend/features/mail/SMTP auth username (auth skipped if absent)
SMTP_PASSbackend/features/mail/SMTP auth password (auth skipped if absent)
SMTP_FROMno-reply@localhostbackend/features/mail/Default From address
SMTP_SECUREfalsebackend/features/mail/Set to "true" for implicit TLS (port 465)

OpenPanel Analytics (opt-in, frontend)

Feature is disabled when BUN_PUBLIC_OPENPANEL_CLIENT_ID is absent. See frontend/features/analytics/README.md.

BUN_PUBLIC_ prefix is required for Bun to expose variables to the frontend bundle at build time.

VariableDefaultUsed byPurpose
BUN_PUBLIC_OPENPANEL_CLIENT_IDfrontend/features/analytics/OpenPanel project Client ID; absence disables analytics
BUN_PUBLIC_OPENPANEL_API_URLfrontend/features/analytics/OpenPanel collector URL (for self-hosted instances)

Runtime Config Injection

Frontend variables (BUN_PUBLIC_*) are normally baked into the bundle at build time. For deployments that supply env vars at runtime (e.g. Coolify, Docker without build args), backend/serveProdBuild.ts injects a window.__APP_CONFIG__ object into the HTML at request time:

<script>
  window.__APP_CONFIG__ = {
    BUN_PUBLIC_OPENPANEL_CLIENT_ID: '...',
    BUN_PUBLIC_OPENPANEL_API_URL: '...',
  };
</script>

The frontend reads from window.__APP_CONFIG__ first, then falls back to import.meta.env.


Adding a New Variable

  1. Add the variable to .env.example (no value — just the key and a comment)
  2. Add a typed declaration to bun-env.d.ts in the Bun.Env interface
  3. If it’s a BUN_PUBLIC_* variable also add it to ImportMetaEnv and Window.__APP_CONFIG__ in bun-env.d.ts
  4. Update this document