Guides

Environment variables

Project vs service env, build-time vs runtime injection, and when changes redeploy.

Scopes

ScopeWhereUse for
ProjectProject → EnvironmentShared defaults inherited by services
ServiceService → EnvironmentOverrides and service-only secrets

Sensitive values are encrypted at rest. Prefer service scope for credentials that must not leak across services.

Build-time vs runtime

Service typeWhen vars are applied
StaticBuild time — baked into the asset bundle. Changing env triggers a rebuild.
Web / worker / cronRuntime injection (and during image build when a build step runs)

Saving env that requires a new process or build typically queues an env_change redeploy.

Public / client prefixes

Values that must ship to the browser (Next.js NEXT_PUBLIC_*, Vite VITE_*, etc.) are available at build time for frameworks that inline them. Treat public prefixes as non-secret.

Platform-injected vars

Bytstack also injects platform metadata into workloads (do not set these yourself unless you know why):

VariableMeaning
PORTHTTP listen port for web services
NODE_ENVTypically production
DATABASE_URLInternal DB URL when a database is attached
BYTSTACK_SERVICE_IDCurrent service id
BYTSTACK_DEPLOYMENT_IDCurrent deployment id
BYTSTACK_APEX_HOSTApex host for path-based SaaS routing
BYTSTACK_API_PATHAPI path prefix when using path split
BYTSTACK_EDGE_TARGETEdge routing target metadata

See Platform reference for more.

CLI

bytstack env set KEY=value

Listing and deleting vars is done in the dashboard today.

Naming tips

  • Use conventional names (DATABASE_URL, REDIS_URL) so frameworks pick them up.
  • Never commit secrets to git — store them in Bytstack env.