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

> ## Agent Instructions
> These are the docs for Sevalla, a platform for deploying applications, databases, static sites, object storage and load balancers. The dashboard is at https://app.sevalla.com.
> Bold text in steps is an exact dashboard label.
> To act on a Sevalla account, prefer the Sevalla MCP server (https://mcp.sevalla.com/mcp, see https://docs.sevalla.com/ai-agents/overview.md), then the Sevalla CLI (https://docs.sevalla.com/developer-tools/cli.md), then the REST API (https://api-docs.sevalla.com, OpenAPI spec at https://api.sevalla.com/v3/openapi.json).
> Every page index is at https://docs.sevalla.com/llms.txt.

# Environment variables

> Give a static site's build configuration and API keys as environment variables: add, update, delete, import and export them, scope them to production or previews, and reference one in another.

A static site's environment variables are key-value pairs that Sevalla passes to the build. Your build command reads them like any other environment variable, for example to fill in an API URL. They exist only while the site builds: a static site has no server, so nothing reads them when visitors load a page.

> [!WARNING]
>
> A value your build writes into the site's files is public. Frameworks embed variables with prefixes such as `VITE_`, `NEXT_PUBLIC_` or `PUBLIC_` into the JavaScript they output. Never give the build a secret that ends up in the published files.

## How variables work

* **Changes apply from the next deployment.** Adding, updating or deleting a variable doesn't rebuild the site: [deploy it](https://docs.sevalla.com/static-sites/deployments.md#deploy-by-hand) to use the change.
* **Each variable is for production, previews or both.** With [pull request previews](https://docs.sevalla.com/static-sites/deployments.md#pull-request-previews) on, you choose **Production**, **Preview** or both for each variable. Production deployments use the **Production** variables, preview deployments the **Preview** ones. Without previews, new variables are production only.
* **A key can exist once per environment**: once for production and once for previews, with different values. Adding a key that already exists for the same environment fails with `This key already exists on the static site`.
* **Values are encrypted** when Sevalla stores them, and masked in the dashboard until you reveal them.
* **One variable can use another.** Write `${KEY}` in a value to insert the value of the variable `KEY` from the same environment, for example `${API_HOST}/v2`. References can nest up to 10 levels. A reference to a key that doesn't exist stays as written.
* **Global variables don't apply.** The company's **Global variables** (**Tools** > **Global variables**) are for applications only.

## Add environment variables

**1. Open the variables**

In the sidebar, click **Static sites**, then click the site. Click the **Environment variables** tab.

**2. Open the add sheet**

Click **Add environment variables**.

**3. Enter the variables**

Enter a **Key** and a **Value**. Click **Add another** for more rows, click **Import .env** to load a `.env` file, or paste a `.env` file's contents into a key field. With previews on, choose the **Availability**: **Production**, **Preview** or both.

**4. Save them**

Click **Add environment variables**.

The variables appear in the list, with their availability when previews are on. Each needs a key and a value, and a key can appear once per sheet (`Key is required`, `Duplicate key`). [Deploy the site](https://docs.sevalla.com/static-sites/deployments.md#deploy-by-hand) to use them.

![The Add environment variables sheet with Production and Preview availability checked, one key and value, Add another and Import .env](https://assets.sevalla.com/screenshots/light/static-site-environment-variables-add.png)

You can also add variables when you [create the site](https://docs.sevalla.com/static-sites/create.md#environment-variables).

## Update an environment variable

**1. Open the variable**

On the site's **Environment variables** tab, open the variable's menu and click **Update**.

**2. Change it**

Update the **Key**, the **Value** or the **Availability**, then click **Update environment variable**.

The **Availability** choice shows here even with previews off, so you can change where an existing variable applies. Deploy the site to use the change.

## Delete environment variables

**1. Choose the variables**

On the site's **Environment variables** tab, open a variable's menu and click **Delete**. To delete more than one, select their checkboxes and click the button that names how many, for example **Delete 3 variables**.

**2. Confirm**

Click **Delete variable** (or **Delete 3 variables**).

The variables are removed from the next deployment on. You can't undo this.

## Find, copy and export variables

* **Filter by key…** narrows the list to keys that contain what you type.
* **Copy all** copies every variable to the clipboard in `.env` format.
* **Export** downloads every variable as a file named `export.env`.

## API and CLI

| Task | API | CLI |
| - | - | - |
| List variables | [List static site environment variables](https://api-docs.sevalla.com/v3/static-sites/list-static-site-environment-variables) | `sevalla static-sites env-vars list --site-id <id>` |
| Add a variable | [Create static site environment variable](https://api-docs.sevalla.com/v3/static-sites/create-static-site-environment-variable) | `sevalla static-sites env-vars create <site-id> --key API_URL --value https://api.example.com` |
| Update a variable | [Update static site environment variable](https://api-docs.sevalla.com/v3/static-sites/update-static-site-environment-variable) | `sevalla static-sites env-vars update <env-var-id> --site-id <id> --value https://api.example.com/v2` |
| Delete a variable | [Delete static site environment variable](https://api-docs.sevalla.com/v3/static-sites/delete-static-site-environment-variable) | `sevalla static-sites env-vars delete <site-id> <env-var-id> --confirm` |

The API sets the environments with `is_production` and `is_preview`, both `true` unless you say otherwise. Its `branch` field limits a preview variable to one branch: previews of other branches don't get it, and production deployments ignore the field.


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