Using environment variables (Components at Edge)
| Want an interactive way to learn about components? Check out the DXP Component Library for best practice examples. |
This tutorial explains how to use environment variables with Components at Edge components: declare variables in the manifest.json file, read info.env in your entry code, and test values locally and in the Squiz DXP.
You define environment variables at the component set level in the DXP, and you can override them for each component. They are suited to individual-site branding, feature flags, API endpoints, and other values that should not be hard-coded.
Read the Environment variables module for the full reference documentation without the step-by-step path.
Prerequisites
-
A Components at Edge component. For example, you have already followed the Components at Edge or Create a component documentation to create one.
-
Node.js and the DXP CLI installed. Read the CLI prerequisites and Pre-requisites documentation as needed.
-
Access to the Squiz DXP Console to manage component sets and variables when testing in the DXP.