Skip to content

Environment variables

vars are public, non-secret values. Structured-clone-compatible JSON enters env.

json
{
  "name": "hello-typescript",
  "main": "src/index.ts",
  "vars": {
    "GREETING": "Hello from TypeScript"
  }
}
ts
export default {
  fetch(_request: Request, env: Env): Response {
    return new Response(env.GREETING);
  },
} satisfies ExportedHandler<Env>;

bun run oc types writes literals into worker-configuration.d.ts (for example GREETING: "Hello from TypeScript"). Regenerate types after changing vars. Offline bundles do not contain vars; run / deploy inject them.

Compatibility

TopicCloudflareopen-compute
Public strings/JSON on env, not secretsYes — Environment variablesYes
Wrangler [vars] TOMLYesNot provided
Dashboard editor / Wrangler environments productYesNot provided
Unknown top-level keysMay be ignoredFail the whole project config
Where secrets liveSecrets productsecrets, not vars