Caution: The Wix CLI is in Developer Preview and is subject to change.
Configure and use environment variables in your Wix CLI project to store configuration values and secrets outside of your code. Learn about the types of environment variables available in Wix CLI projects.
In this step, you define the structure of your environment variables in astro.config.mjs, specifying each variable’s type, context (client or server), and access level (public or secret) before assigning actual values.
Read more about the schema definition in the Astro documentation.
In this step, you configure public or secret variables.
To configure public variables:
.env.local file in your project root.wix env set command to set the variables.Important:
Don't edit any of the WIX_CLIENT variables in the .env.local file. The Wix CLI manages these variables.
To configure secret server variables:
wix env set command to set the secret variable.wix env pull command.Note: You must run wix env pull after setting secret variables. Without running wix env pull, the wix dev command doesn't work.
In this step, you learn how to import and use environment variables.
Import public client variables from astro:env/client. The following example imports and uses the API_URL variable.
Import public server and secret variables from astro:env/server:
After setting your environment variables, build and release your project to apply the changes.
To build and release: