Skip to main content
Edit configuration in the workspace.

Environment Variables

The environment variables page lets you add, change, remove and copy the installation’s environment variables.
Installation settings environment variables page
Environment variables are key-value pairs for installation configuration that you wouldn’t want to put in code or in a table, such as a log level or which external account an installation uses. You can set environment variables in Bijection through the console and access them in functions. An environment edit stages configuration for the next deploy. The active program keeps the values captured when it was deployed. Store credentials as secrets. Functions read a variable through process.env.

Values at declaration time

A declaration that needs configuration, such as a receiver’s endpoint, reads it with env:
bijection/crm.ts
env(name, fallback?) reads the variable name when the declarations are evaluated: on deploy, the installation’s environment variable of that name (set it with bijection env set CRM_URL https://crm.example.com); in a local bijection check, the shell’s. Without a fallback, an unset variable refuses the deploy. Pass the name as a string literal: the CLI supplies the variables the source names, and bijection check --definition-inputs <file> overrides them from a JSON map. The lock records the variable name as env CRM_URL. Deploy records the value it evaluated in the installation’s program fact. Use secrets for credentials. env("NAME") in the installation bindings file, in a provider’s parameters or a sync destination’s configuration, is different: it stays a reference, and the host resolves it from the installation’s environment variables when it prepares the deploy, for a deploy from your machine and a hosted build alike. The deploying shell’s variables are never read. A variable with no value refuses the deploy with PlacementUnavailable (InputMissing) on the slot that needs it, and a changed value takes effect at the next deploy. See placement. Sign-in issuers are evaluated at deploy and appear in the lock with their resolved audience, key source and trust settings. A deploy applies the staged configuration with its reviewed program. Use bijection deploy --trial to see changes to declaration inputs.

Setting environment variables

Under Installation Settings in the console, you can see a list of environment variables in the current installation.
Environment variables table
You can add up to 512 environment variables, and the total size of all environment variables (names + values) cannot exceed 512KiB. Environment variable names cannot be more than 256 characters long, and they must start with a letter and only contain letters, numbers, and underscores. Environment variable values cannot be larger than 8KiB. You can modify environment variables using the pencil icon button:
Edit environment variable
Environment variables can also be viewed and modified from the command line.

Using environment variables in dev and prod installations

Since environment variables are set per-installation, you can use different values for the same key in dev and prod installations. This can be useful for when you have different external accounts you’d like to use depending on the environment. For example, a MAIL_FROM variable can name a different sender address in dev and prod. If you expect an environment variable to be always present in a function, you must add it to all your installations, with the value each installation needs.

Configuring a mounted app

A mountable app is a function from its capabilities to app(...), so an installer passes configuration as arguments when it calls the app at a path in its tree, and needs no environment variable for it:
A credential is never configuration: declare it with secret() in the tree and set its value as an operator with bijection secret set <path>. See Secrets.

System environment variables

The following environment variables are always available in Bijection functions:
  • BIJECTION_CLOUD_URL - Your installation URL (eg. https://dusty-nightingale-847.bijection.cloud) for use with Bijection clients.
  • BIJECTION_SITE_URL - Your installation’s HTTP URL (eg. https://dusty-nightingale-847.bijection.run), where route reactions are served

Project environment variable defaults

You can set up default environment variable values for a project in Project Settings.
Project default environment variables
These default values will be used when creating a new installation, and will have no effect on existing installations (they are not kept in sync). You can set a different default value for each installation type and, through the Management API, for a single installation reference, whose defaults override its type’s by name. Developers and admins can read and change project defaults; viewers and deploy keys cannot. The Installation Settings will indicate when an installation has environment variables that do not match the project defaults.
Environment variable default mismatch
You can also change the default environment variables from the CLI using bijection env default.