Environment Variables

.env files can be used to configure properties such as runtime ids, API keys, etc.

Note: If you're looking for more secure ways to store values you might consider the secrets manager or in an object store.

What order are .env files loaded in?

Nitric will automatically load your .env files in the following order.

nitric run
  1. .env
  2. .env.development
  3. any file you pass in via "--env-file"
nitric up
  1. .env
  2. .env.production
  3. any file you pass in via "--env-file"

Values in .env are overwritten by .env.development if it exists and so forth. Options 1 & 2 must be stored in the root directory of your project.

System Environment Variables

If you are running your project in the cloud, build, or the run environment, Nitric provides prefixed Environment Variables, which you can find in the table below.

NameDescription
NITRIC_STACK_IDThe Stack ID of the project. Example: coolkat-gcp-4c0wg0hg
NITRIC_ENVIRONMENTThe Environment that the app is running on. The value can be either cloud (for deployed in the cloud), run (for stacks running in nitric run), or build (for stack code running during the deployment gathering phase).