Environment variables

Each Begin app’s environments has its own set of independently configurable environment variables.

Creating environment variables

To add an environment variable, use the Begin CLI to execute the following command:

begin env create --env staging --name "FOO" --value "bar"
b env create --env staging --name "FOO" --value "bar"

We recommend quoting environment variable names and values on the CLI in order to avoid unintended parsing issues.

Editing variables

To modify an existing environment variable, run the same command as before, using the name of the variable you want to change and the new value you want to apply to it.

begin env create --env staging --name "FOO" --value "baz"
b env create --env staging --name "FOO" --value "baz"

Listing variables

To see which environment variables exist for a given environment, use the Begin CLI to list them:

begin env list --env staging
vanilla-to-ssr (app ID: XXXXXXXX)
└── staging (env ID: STGXXXXX): https://local-fih.begin.app
    └── FOO=b***
b env list --env staging
vanilla-to-ssr (app ID: XXXXXXXX)
└── staging (env ID: STGXXXXX): https://local-fih.begin.app
    └── FOO=b****

Deleting variables

To delete a variable, simply run the destroy command:

begin env destroy --env staging --name "FOO"
b env destroy --env staging --name "FOO"

Local development

When working in your local development environment, environment variables must be provided by a .env file within your project. One environment variable can be declared per line in the file, with the key and value separated by an equals (=) sign. For example:

FOO=bar
API_KEY=super-secret

Never check in your .env file to source code control. We recommend including the .env file in your project’s .gitignore to prevent accidentally leaking secrets.