Environment variables allow you to store configuration values and secrets outside of your code, making your apps more secure and portable. In a Wix CLI app, backend code reads environment variables from process.env. Frontend code, such as dashboard pages and site widgets, can't read the environment variables you define.
This article explains where environment variables are stored in Wix CLI projects and which code can read them.
An environment variable's storage location determines where its value is available.
| Storage location | How you set it | Where the value is available |
|---|---|---|
| Wix servers | The wix app env set command. | Deployed code in preview and release builds. Local development after you run wix app env pull. |
.env.local file only | Add the variable to the .env.local file in your project root. | Local development only. The value doesn't reach preview or production builds. |
Store every value that your deployed code needs on Wix servers, including sensitive values such as API keys:
wix app env set are stored on Wix servers and shared with your project's collaborators.process.env.wix app env pull. The command merges the variables from Wix servers into your .env.local file.A variable that you add only to .env.local stays on your computer. Use .env.local alone only for values that you need in local development and not in deployed code.
The project's .gitignore file excludes .env.local, so pulled values aren't committed to your repository. Keep .env.local out of source control.
.env.local also contains WIX_CLIENT_* variables, which the Wix CLI manages. Don't edit them.
Backend code, such as HTTP endpoints, event extensions, and service plugins, reads environment variables from process.env.
Frontend code, such as dashboard pages and site widgets, can't read the environment variables you define. If frontend code needs a non-sensitive configuration value, have it call an HTTP endpoint that returns the value. Don't return sensitive values to frontend code.
Last updated: 11 November 2026