> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Manage Environment Variables in the CLI

## Article: Manage Environment Variables in the CLI

## Article Link: https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/project-development/environment-variables/manage-environment-variables-in-the-cli.md

## Article Content:

# Manage Environment Variables in the CLI


Configure and use environment variables in your Wix CLI project to store configuration values and secrets outside of your code. Learn about [how environment variables work](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/project-development/environment-variables/about-environment-variables-in-the-cli.md) in Wix CLI projects.

## Step 1 | Set environment variables

In this step, you store your variables on Wix servers and pull them into your local environment.

To set environment variables:

1. Set each variable with the [`wix app env set`](https://dev.wix.com/docs/wix-cli/cli-for-apps/command-reference/project-commands/env.md#set) command. The command stores the variable on Wix servers and shares it with your project's collaborators.

    ```bash
    wix app env set --key=API_BASE_URL --value=https://api.example.com
    wix app env set --key=API_SECRET_KEY --value=your-secret-value
    ```

    The command has no flag that marks a variable as secret. Every variable you set is stored the same way, and only backend code can read it.

2. To use the variables in local development, pull them with the [`wix app env pull`](https://dev.wix.com/docs/wix-cli/cli-for-apps/command-reference/project-commands/env.md#pull) command. The command merges the variables from Wix servers into your `.env.local` file.

    ```bash
    wix app env pull
    ```

A variable that you add only to `.env.local` stays local. It doesn't reach preview or production builds. To make a value available to deployed code, set it with `wix app env set`.

<blockquote class="important">

__Important:__
- Don't edit any of the `WIX_CLIENT` variables in the `.env.local` file. The Wix CLI manages these variables.
- Don't commit `.env.local` to source control. The project's `.gitignore` file excludes it by default.

</blockquote>

## Step 2 | Use environment variables in your code

In this step, you read environment variables in your code.

### Use backend variables

Backend code, such as HTTP endpoints, event extensions, and service plugins, reads environment variables from `process.env`. Every value is a string.

To get TypeScript types for `process.env`, install the Node.js type definitions if your project doesn't already include them:

```bash
npm install --save-dev @types/node
```

The following example reads the `API_BASE_URL` and `API_SECRET_KEY` variables:

```ts
const apiBaseUrl = process.env.API_BASE_URL;
const apiSecretKey = process.env.API_SECRET_KEY;

const response = await fetch(`${apiBaseUrl}/data`, {
  headers: {
    "Authorization": `Bearer ${apiSecretKey}`
  }
});
```

### Frontend code

Frontend code, such as dashboard pages and site widgets, can't read the environment variables you define. If frontend code needs a configuration value, create an [HTTP endpoint](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/supported-extensions/backend/http-endpoints/about-http-endpoints.md) that returns the value, and call the endpoint from your frontend code. Don't return secret values to frontend code.

## Step 3 | Build and release your project

After setting your environment variables, build and release your project to apply the changes.

To build and release:

1. [Build](https://dev.wix.com/docs/wix-cli/cli-for-apps/command-reference/project-commands/build.md) your project.

```bash
wix app build
```

2. [Release](https://dev.wix.com/docs/wix-cli/cli-for-apps/command-reference/project-commands/release.md) your project to apply the changes.

```bash
wix app release
```

## See also

- [About Environment Variables](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/project-development/environment-variables/about-environment-variables-in-the-cli.md)
- [Build and Deploy an App with the Wix CLI](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/wix-cli/project-development/build-and-deploy-a-project-with-the-wix-cli.md)