Skip to content

Environment variables

The yofix env commands manage the environment variables a project uses at build and run time. Variables are scoped to one or more targets (for example preview and production), so a value can differ between environments or be shared across them.

List variables

Terminal window
yofix env list

Values are masked. To see only the keys (handy for scripting):

Terminal window
yofix env list --plain
yofix env list --target production

Set a variable

Terminal window
yofix env set API_URL https://api.example.com

By default a new variable applies to both preview and production. Scope it to specific targets with a repeatable --target:

Terminal window
yofix env set API_URL https://staging.example.com --target preview
yofix env set STRIPE_KEY --target production --secret

Omit the value to read it from stdin, which keeps secrets out of your shell history:

Terminal window
echo -n "$STRIPE_KEY" | yofix env set STRIPE_KEY --target production --secret

--secret marks the variable write-only: it can be set and used in builds, but never read back.

Read a single variable

Terminal window
yofix env get API_URL
yofix env get STRIPE_KEY --reveal # fetch the plaintext value (audited)

Revealing a value is logged server-side.

Delete a variable

Terminal window
yofix env unset OLD_FLAG # removes it across all targets
yofix env unset OLD_FLAG --yes # skip the confirmation prompt

Pull values into a dotenv file

Write every variable (with values) to a local dotenv file for local development. Each value is revealed, so this action is audited:

Terminal window
yofix env pull # writes .env.local
yofix env pull .env.production --target production

Import from a dotenv file

Bulk-load variables from an existing file:

Terminal window
yofix env import .env.production --target production
yofix env import .env --replace-existing

Without --replace-existing, keys that already exist are left untouched.

Clone between targets

Extend a variable’s targets so the same value also applies elsewhere, without re-entering it:

Terminal window
yofix env clone --from preview --to production

This adds production to the targets of every variable currently scoped to preview. The value stays shared; it is not copied.

Flags

CommandNotable flags
env list--target <env>, --plain
env get--reveal
env set--target <env...>, --secret
env unset-y, --yes
env pull--target <env>
env import--target <env...>, --replace-existing
env clone--from <target>, --to <target> (both required)

Next