> For the complete documentation index, see [llms.txt](https://docs.release.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.release.com/reference-documentation/environment-settings/environment-specific-environment-variables/environment-variable-mappings.md).

# Environment variable mappings

Why and how to use environment variable mappings

There are many reasons you may want to use environment variables in your application, for example, to provide a backend URL for your frontend.

Here is an example `config.js` for a React application:

```yaml
export default {
  API: process.env.REACT_APP_BACKEND_BASE_URL,
  FRONTEND_URL: process.env.REACT_APP_FRONTEND_BASE_URL
};
```

In this example, Release will autogenerate ingress URLs for the application to expose ports:

```yaml
- key: BACKEND_INGRESS_URL
  value: https://api.releaseapp.io
- key: FRONTEND_INGRESS_URL
  value: https://app.releaseapp.io
```

In order for the frontend application to use the URLs autogenerated by Release, you can map the application's environment variables to the autogenerated environment variables. You can map environment variables in an application's [default environment variables](/reference-documentation/application-settings/default-environment-variables.md) or in the [environment-specific environment variables](https://github.com/releasehub-com/docs/blob/main/reference-documentation/environment-settings/environment-specific-environment-variables.md).

Here is an example environment variable mapping:

```yaml
mapping:
  REACT_APP_BACKEND_BASE_URL: BACKEND_INGRESS_URL
  REACT_APP_FRONTEND_BASE_URL: FRONTEND_INGRESS_URL
```

Mappings are expressed as key-value pairs, with the application's environment variable as the key and the Release autogenerated environment variable as the value.

### Interpolation

Environment variable mappings are also the only place where interpolation can occur. You can try to interpolate variables together to create a new string:

```yaml
mapping:
  DB_URL: "postgres://${DB_USER}:${DB_PASS}@${DB_HOST}:${DB_PORT}/${DB_NAME}
```

You can also use bash interpolation rules for fallback if the variables are not present. As an example, your frontend may use an [app import](https://github.com/releasehub-com/docs/blob/main/reference-documentation/environment-settings/environment-specific-environment-variables/broken-reference/README.md) to connect to a backend. If the backend is not present, however, it can fallback to a staging environment.

```
mapping:
  BACKEND_URL: ${BACKEND_INGRESS_URL:-https://staging.example.com}
```

### Deploy Your Changes

Once you have added your environment variable mapping, save the configuration and deploy.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.release.com/reference-documentation/environment-settings/environment-specific-environment-variables/environment-variable-mappings.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
