Devflare Docs
Configuration Devflare

Resolve values through typed config vars instead of scattering process env reads

Use descriptors inside , parse or default them in config, and read the resulting typed values at runtime with .

Devflare vars can now be a typed bridge from local files into Worker runtime code. The config owns which variables are required, optional, parsed, or dev-only, while application code reads the resolved shape through the runtime helper.

Config import
Runtime import
File order
Parents first, then closer directories; , ,
Missing build vars
Build fails with a nested missing-variable report

Declare the runtime shape in config

The export from does not read the variable immediately. It creates a descriptor that Devflare resolves when it starts dev, builds artifacts, or prints a phase-resolved config.

That keeps config import cheap and lets Devflare report every missing variable at once, using the nested path from instead of a generic process-env crash.

Nested vars with required, optional, parsed, defaulted, and dev-only values

Read resolved values through the runtime helper

At runtime, Devflare exposes the resolved values on the Worker environment and through the helper. The helper is typed from , so parser return values and nested objects stay visible to TypeScript.

Unparsed environment descriptors resolve to strings. Parsed descriptors use the parser return type, defaults contribute their value type, and optional descriptors become optional properties.

Runtime code can use the nested shape directly

Let Devflare parse files itself

Devflare reads , and from the config directory and every parent directory. Parent files load first, then closer files override them. Within one directory the order is , then , then , so a developer file always wins over one the repository ships.

is the tier meant to be committed. Every other env file is conventionally git-ignored, which leaves values that are genuinely not secrets — a sender address, a support forwarding target, a public API origin — with nowhere to live but a deploy dashboard. It is deliberately the weakest tier so a committed default can never override the machine it runs on.

The parser does not expand references. Values such as passwords, MongoDB connection strings, and shell-looking fragments are read as written instead of being interpreted by Bun.

A script that must know what a command will see — a predeploy check that refuses a committed dev value, say — can ask the same layer instead of re-implementing it. lists every candidate file in load order, reads one file the way Devflare does, and returns the merged and the that supplied them. All three come from and none of them touches .

The same script may need the config itself without the files: grading a production config under a controlled environment, say, where an untracked on the machine running the check must not decide the answer. skips this layer and nothing else: the config is evaluated with as it stands, and c12 still picks the file and applies . then compiles it offline the way does — the overrides merged in and applied last — keeping a KV, D1 or Hyperdrive binding that is configured by name as a name, where would need its id.

That is not everything a deploy ships. An var descriptor stays the descriptor object in that output, where a deploy resolves it from and these files, included — so a check reading as strings must resolve them first, or treat a descriptor as unresolved rather than safe.

resolves them as and do: the environment merged first, then each descriptor in mode, where and do not apply. A descriptor reads and nothing else — no file, and only if that is what you pass, as a plain object such as . A required variable with no value does not throw: the call returns , with that variable listed in and absent from , so a check can grade a correct config that nobody has provisioned yet. The returned has its sections removed, since the target is merged in already. Compile it with , as does.

Two more things differ from a deploy. Preview-scoped names read from — in too, which materialises them as a build does — and clears those variables, so the check must clear them too. And Bun loads , and from the working directory before any of this runs, so run such a check with .

Process env still wins over files

CI-provided environment variables and explicit shell exports override file values. Dotenv files fill in missing process variables; they do not stomp values the process already had.

is a promise you keep, not one Devflare checks

Anything committed to is in version-control history permanently. Devflare cannot tell a sender address from an SMTP URL with a password in it, so nothing validates the name — treat it as documentation of intent, and keep secrets in or .

reaches production deploys too

The three files are loaded by every command that loads a config, whatever its mode: reads exactly as does. The name says whose machine the file serves, not which builds it reaches — so a dev-only flag kept there ships with a production deploy run from that machine.

The later `.env` value overrides the earlier `.env.dev` value

Code sample type: dotenv

Missing required values fail build and pause dev

Required is the default because a config variable usually means the Worker cannot run honestly without that value. Build and config-inspection commands fail with a grouped report that points at the nested path and the missing environment variable name.

Dev mode is gentler. It prints the same report, waits for or to change, and then retries startup. That makes the local loop fixable without restarting the command.

Missing variables are grouped by the config path that required them

Code sample type: text

Use helpers to make intent explicit

HelperMeaningExample
Required string value.
Missing value is allowed and omitted.
/ Transform the string from env files into a typed runtime value.
Use a fallback in every mode when the env value is missing.
Use a fallback only in dev when the env value is missing.
Required for a build; dev runs without it unless something supplies one.

Dev-only defaults are still required in build

is intentionally local-only. If the same variable may be missing in build too, use or instead.

is the third answer, not a synonym for the other two

Some variables a deployment must have are ones a developer must not. A sender address is the clearest case: with none set, code that shape-checks its environment takes its cannot-send path, which is how local development returns a sign-in code instead of mailing one. would let a production build ship without it, and would hand every laptop a placeholder it then believes. fails the build and omits the key locally, and the inferred type is optional because in dev it genuinely is.

Never put an variable in

Absent by default is not the same as forbidden — a value that is genuinely present still wins, in dev as everywhere else, so a developer who deliberately exports one to point their machine at a real sender gets it. That is the intended escape hatch, and it is also the trap: is committed, so a value written there reaches every checkout and hands the exact placeholder to every laptop the descriptor exists to withhold. Supply it from the deployment — a CI variable or the dashboard — or from a developer's own git-ignored .

Previous

Environments

Keep one base config, layer environment-specific overrides with , and let Devflare resolve preview or production details only in the commands that actually need them.

Next

Previews

Use for bindings that should belong to one preview scope. Devflare materializes names like , provisions or reuses the preview-only resources it can manage, and lets you clean them up by the same scope later without touching production resources.