Skip to Content
Omnibase
Deployments

Environment Variables & Secrets

How variables reach your deployments — build-time injection, {VAR} interpolation in wrangler configs, and where secrets live

Environment Variables & Secrets

Deployments get variables from your omnibase/.env.* files. There are two distinct moments variables are used, and it's important to know which is which:

  1. Build time — when the worker is compiled, variables are injected into the build process.
  2. Runtime — when the worker runs, variables in the wrangler config [vars] are baked into the deployed worker.

Resolution Order

Wherever a value is needed, it resolves per key, first non-empty wins:

process.env → omnibase/.env.<env> (selected with --env) → the literal {VAR} left in place

Build-Time Variable Injection

omnibase cloud workers deploy runs bunx wrangler deploy --dry-run --outdir .bundle in each deployment directory with the resolved variables exported into the build process. Whatever your build.command reads from the environment is available while it runs.

This matters for anything that inlines values at build time — bundled client assets, generated config, static pages. Put those keys in the env file for the branch you're deploying:

# omnibase/.env.main
PUBLIC_API_URL=https://api.my-app.com
PUBLIC_WEBSITE_URL=https://my-app.com

Then deploy:

omnibase cloud workers deploy --env main

The values are present when the build runs, so they end up baked into the output bundle.

Runtime Variables and {VAR} Interpolation

Runtime values live in the [vars] section of your deployment's wrangler config. Omnibase interpolates {VAR} references at package time, replacing each placeholder with the resolved value from omnibase/.env.<env>.

// apps/api/wrangler.jsonc
{
  "vars": {
    "PUBLIC_WEBSITE_URL": "{PUBLIC_WEBSITE_URL}",
    "OMNIBASE_API_URL": "{OMNIBASE_API_URL}"
  }
}

With PUBLIC_WEBSITE_URL=https://my-app.com in omnibase/.env.main, deploying --env main packages the worker with PUBLIC_WEBSITE_URL set to https://my-app.com.

This works the same in every wrangler format:

{
  "vars": {
    "OMNIBASE_API_URL": "{OMNIBASE_API_URL}"
  }
}

Unresolved {VAR} references are left literal and the CLI warns, so a typo'd key shows up at deploy time rather than silently failing later.

Secrets

Never put secrets in [vars]. Values in [vars] are visible in the deployed worker (they're embedded in the worker's environment). For API keys, signing secrets, and tokens use either:

  • wrangler secret — stored as a Worker secret at deploy time
  • The managed-hosting secrets API — secrets injected into the branch environment

omnibase/.env.* files are gitignored, so local secrets like Stripe keys stay off-disk-committed, but anything needed at runtime in the deployed worker should still go through wrangler secret.

On this page