strackt docs
Browse docs

How To

Manage environment variables

Set the environment variables and secrets your application reads at runtime.

Manage environment variables

Your application's environment variables — API keys, database URLs, feature flags, anything your code reads from the environment — live in strackt and are written to the server at deploy time. Changes you make here take effect on the next deploy.

Setting a variable

Use the CLI to add or update a variable:

strackt env:secrets set KEY value
strackt env:secrets set --env staging KEY value

If you have a local .env file you want to use as the source, you can sync the whole set at once:

strackt env:secrets sync --file .env.production

Add --prune to remove any variables you've previously set that aren't in the file.

You can also set and update variables through the API for scripted or CI-based workflows.

How variables reach your application

At deploy time, strackt builds the final .env your application reads. It starts from the config template you've set up, then layers in the variables you've stored:

  • If a variable already appears in the template, the stored value replaces it in place.
  • If a variable doesn't appear in the template, it's appended in a clearly-marked section at the end.

Secret values are never written to deploy logs.

Variables from connected services

When your application connects to a database or cache service, strackt wires in the connection details automatically. You don't need to copy a host, port, or password — they appear as tokens in your config template and resolve to the live values at deploy time.

If you're writing your template by hand, the Binding Variables sidebar in the template editor shows every available connection token. Clicking one inserts it at the cursor.

Rotating a secret

To update a variable — for example, a rotated API key — overwrite it with the new value:

strackt env:secrets set STRIPE_SECRET_KEY sk_live_newvalue

The updated value takes effect on the next deploy. You don't need to change the template.

Keeping track of what's set

To list the variables currently stored for an environment:

strackt env:secrets list

Values are masked by default. If you need to see the actual value, your token needs reveal access:

strackt env:secrets list --reveal

Was this helpful?

Related docs