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 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 command. The command stores the variable on Wix servers and shares it with your project's collaborators.

    Copy

    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 command. The command merges the variables from Wix servers into your .env.local file.

    Copy

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.

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.

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:

Copy

The following example reads the API_BASE_URL and API_SECRET_KEY variables:

Copy

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 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 your project.
Copy
  1. Release your project to apply the changes.
Copy

See also

Last updated: 11 November 2026

Did this help?