# Environment variables

Source: https://docs.myhub.host/environment

## Add a secret

For an app you have already deployed:

```sh
hub app my-app env set API_KEY
```

Paste the value at the hidden prompt. Hub saves it and creates a release to apply the change.

```sh
hub app my-app status
```

## Import a .env file

```sh
hub app my-app env set --file .env
```

Keep this file out of source control. Saved values are encrypted and are not shown in variable listings.

## Configure a frontend build

```sh
hub app my-app env set --build VITE_API_URL=https://api.example.com
```

Hub rebuilds the app. Frontend build values can appear in the published files, so use them only for public configuration.

Variables belong to one [instance](https://docs.myhub.host/instances). In Compose, pass them to services using `${NAME}`; see the [database example](https://docs.myhub.host/deploy/compose).

[Environment command reference](https://docs.myhub.host/cli/app/env)