> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Environment Variables

Edit configuration in the workspace.

## Environment Variables

The
[environment variables page](https://console.bijection.com/deployment/settings/environment-variables)
lets you add, change, remove and copy the installation's
[environment variables](https://docs.bijection.com/operate/configuration/environment-variables.md).

![Installation settings environment variables page](https://mintcdn.com/bijection-95ba84d3/MXGsXPKmgvoqOVRN/screenshots/pages_project_deployment_settings_environment_variables.png?fit=max\&auto=format\&n=MXGsXPKmgvoqOVRN\&q=85\&s=613c999caf11886c5ce7ecc247a3bdf6)

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](https://docs.bijection.com/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](https://docs.bijection.com/functions/secrets.md).

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`:

```ts bijection/crm.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { env } from "@bijectionhq/bijection";

/** The CRM's origin, as `receiver({ endpoint: crmUrl, … })` takes it. */
export const crmUrl = env("CRM_URL", "https://crm.example.com");
```

`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](https://docs.bijection.com/functions/secrets.md) 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](https://docs.bijection.com/operate/placement.md#the-bindings-file).

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](https://docs.bijection.com/operate/installations) in the
console, you can see a list of environment variables in the current
installation.

![Environment variables table](https://mintcdn.com/bijection-95ba84d3/MXGsXPKmgvoqOVRN/screenshots/components_deployment_environment_variables.png?fit=max\&auto=format\&n=MXGsXPKmgvoqOVRN\&q=85\&s=6cf49dbddc700b3b0a0f241c5c0c0005)

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](https://mintcdn.com/bijection-95ba84d3/MXGsXPKmgvoqOVRN/screenshots/components_deployment_environment_variables_edit_inline.png?fit=max\&auto=format\&n=MXGsXPKmgvoqOVRN\&q=85\&s=8e7b6f9f62169e5675760b290285c8c1)

Environment variables can also be viewed and modified from the
[command line](https://docs.bijection.com/reference/cli/env).

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection env list --names-only
bijection env get NAME
bijection env set NAME 'value'
bijection env set --from-file .env.bijection
bijection env remove NAME
```

### 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:

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { app, mutation, t, table } from "@bijectionhq/bijection";

// A mountable app: a function from its configuration to app(...).
export function notifier(config: { readonly from: string }) {
  const outbox = table({ from: t.string, to: t.string, text: t.string });
  const queue = mutation({ args: { to: t.string, text: t.string } }, (ctx, { to, text }) =>
    ctx.insert(outbox, { from: config.from, to, text }));
  return app({ outbox, queue });
}

export default app({ notifier: notifier({ from: "orders@example.com" }) });
```

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](https://docs.bijection.com/functions/secrets.md).

## 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](https://docs.bijection.com/functions/reactions.md#routes) are served

## Project environment variable defaults

You can set up default environment variable values for a project in Project
Settings.

![Project default environment variables](https://mintcdn.com/bijection-95ba84d3/MXGsXPKmgvoqOVRN/screenshots/components_project_default_environment_variables.png?fit=max\&auto=format\&n=MXGsXPKmgvoqOVRN\&q=85\&s=5c07fc0c276adbf109ef34a4cff8ffad)

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](https://docs.bijection.com/operate/installations/environments.md#installation-types) and,
through the [Management API](https://docs.bijection.com/reference/http/management), 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](https://mintcdn.com/bijection-95ba84d3/MXGsXPKmgvoqOVRN/screenshots/components_deployment_environment_variables_with_default_diff.png?fit=max\&auto=format\&n=MXGsXPKmgvoqOVRN\&q=85\&s=5fb0774a522c8ff991a2aace1fc78d33)

You can also change the default environment variables from the CLI using
`bijection env default`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.