# Environment Variables

The **Environment Variables** tab within the **Settings** section allows you to define custom variables that are automatically injected into your application’s environment during **builds** and **CodePush** operations. This enables secure and flexible configuration management without hardcoding sensitive values directly into your source code.

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FGANpU389xds5kwhJoTtM%2Fproject-env-variables.png?alt=media&#x26;token=196c9a1d-64fa-4c87-9632-32076fd9e148" alt=""><figcaption></figcaption></figure>

## <mark style="color:red;">What Are Environment Variables?</mark>

Environment variables are key-value pairs used to pass dynamic configuration data to your application at build time. These values can be used to:

* Manage API keys and tokens securely
* Define environment-specific behaviors (e.g., production vs. staging)

They are not stored permanently inside your app, ensuring better security for sensitive data.

## <mark style="color:red;">Example Use Case</mark>

Let’s say your mobile application sends error logs to **Sentry**, and you want the corresponding **map files** to be uploaded during the build process. To do this, the system needs to authenticate with **Sentry’s API**, which requires an **authentication token**.

Because this token is only required during the build process and poses a security risk if stored permanently, it’s ideal to set it as a temporary environment variable. You can define this token as an environment variable in App Maker, ensuring it's available only during the build or CodePush phase.

## <mark style="color:red;">**Adding a New Environment Variable**</mark>

To add a new environment variable:

1. Navigate to the **Environment Variables** tab in your project's settings.
2. Click **"+ Add Environment Variable"**.
3. Fill out the form fields as described below:

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2F76kXJv5xS5VPkmFotKHC%2Fproject-env-variables-add-variable.png?alt=media&#x26;token=7d0d1037-6e4f-4cbd-ae11-b9004c9f881e" alt="" width="563"><figcaption></figcaption></figure>

#### <mark style="color:red;">Name</mark>

* The **name** of the variable must be written in **uppercase** letters.
* Only **letters**, **numbers**, and **underscores (`_`)** are allowed.

*Valid Examples:*

```bash
USERNAME=johndoe@example.com
USER_TOKEN=token_123
```

*Invalid Examples:*

```
username=johndoe@example.com
user-token=token
```

[📘 Learn more about environment variable naming conventions](https://en.wikipedia.org/wiki/Environment_variable)

#### <mark style="color:red;">**Value**</mark>

* The **value** is always treated as a string, even if it represents a number, boolean, or JSON.
* Enter the value associated with the key you defined.

#### <mark style="color:red;">**Build Target**</mark>

You must assign each environment variable to a **build target**:

* **Production:** Used when deploying a live app to end users.
* **Staging:** Used in testing environments for pre-release validation.

{% hint style="info" %}
The correct set of variables will be automatically injected into the environment depending on the target selected during the **Build** or **CodePush** operation.
{% endhint %}

#### <mark style="color:red;">**Is Secret?**</mark>

If the **"Is Secret?"** option is enabled:

* The variable’s value will be hidden in the interface.
* Ideal for API tokens, passwords, and other sensitive data.
* Even after saving, secret values are not visible or retrievable through the UI for security reasons.
