Skip to content
English

Environments

Environments holds variables: values such as a server URL or a token that you’d otherwise retype whenever you edit state, dispatch an action or run a command. Type {{name}} instead, and Xerlock fills in the value before it sends anything to your app.

The Environments section with Base, a staging environment and its variables

Base holds variables every environment shares. Add environments, such as staging or production, for values that differ between them.

One environment is active at a time, or none, which leaves only Base. Switch it from the Active environment menu at the top of the sidebar, or the one in this section.

  • Add one: click New environment, type a name and press Enter.
  • Rename one: double-click its name.
  • Delete one: select it and click Delete environment. Its variables and saved secrets are removed.

Names use letters, numbers and underscores, and can’t start with a number. base is reserved.

Linked apps makes an environment active as soon as one of its apps connects, and shows Switched to …. With your app connected, click Add connected app, or type an app ID and click Add.

Click Add variable and fill in the row. Changes save as you go: Enter or Tab saves a cell, and Escape undoes the change.

Column Takes
Name Letters, numbers and underscores, split into parts with dots: case.apiUrl
Value The value, as text, a number, a switch, or nothing for Null
Type String, Number, Boolean or Null
Secret Whether the value is kept in your system’s keychain

A name can’t also be the start of another name, so case and case.apiUrl can’t both exist, and its first part can’t be base or an environment’s name. Drag a column edge to resize it, or double-click the edge to reset it.

A secret’s value is saved in your system’s keychain (the macOS Keychain, Windows Credential Manager or the Secret Service on Linux), never in Xerlock’s settings. It stays on your computer, is only read when a value is sent to your app, and can’t be shown again once saved. To change it, type a new value. See Keychain.

View as JSON shows every environment as one object. Dots in a name become nested objects, and secrets show as "<secret>":

{
"base": {
"case": {
"apiUrl": {
"value": "http://localhost:3000",
"type": "string",
"secret": false
},
"pageSize": {
"value": 20,
"type": "number",
"secret": false
},
"detective": {
"name": {
"value": "Sherlock Holmes",
"type": "string",
"secret": false
}
}
}
},
"staging": {
"case": {
"apiUrl": {
"value": "https://staging.example.com",
"type": "string",
"secret": false
}
},
"detectiveToken": {
"value": "<secret>",
"type": "string",
"secret": true
}
}
}

Your changes apply when you click out of the editor, if the JSON is valid. It replaces everything: an environment you remove from the JSON is deleted, and renaming one starts it with no linked apps. Leave "<secret>" to keep a secret’s saved value, or type a new one.

Type a reference anywhere a value is sent to your app:

Reference Reads
{{case.apiUrl}} The active environment, then Base
{{case.detective.name}} A nested name, from the active environment, then Base
{{staging.apiUrl}} The staging environment only
{{base.apiUrl}} Base only

They work in:

Inside a JSON or JavaScript string, the value is escaped to fit the quotes. Actions that use a secret aren’t saved in Redux or Zustand’s recent actions.

  • Unknown variable: …: no variable has that name in the active environment or Base. Nothing is sent until it’s fixed.
  • Secret has no saved value: …: the secret was never saved, or the keychain couldn’t be read. Type its value again.
  • Couldn’t save the secret to the keychain: your system refused the keychain write. Check that the keychain is unlocked.
  • Add connected app is disabled while no app is connected.