Environment Variables
The Environment Variables feature enables you to create variables that hold unique values for each application environment (i.e., Development, Staging, and Production). You can use these variables to define component parameters depending on your workspace.
Note: You cannot preview environment variables in the Design view.
To create an environment variable:
- 1.Click the Publish Settings icon in the top menu bar. This opens the Environment Variables Configuration window.
- 2.In the Name field, enter your variable's name. This name enables you to reference the variable in your application.
- 3.In each environment field, enter the value that you want the variable to have in the corresponding environment.Note: The variable's value changes in each environment according to the value that you enter into its corresponding field.
- 4.Click Save.
Once you create an environment variable, you can reference it throughout your application.
You can use environment variables to define component parameters and properties according to your environment. This example outlines how to use the environment variable from Create an environment variable to set a Text component's label in the Development environment:
- 1.Navigate to the Design view and open the Libraries panel.
- 2.Drag-and-drop a Text component into your app.
- 3.Select the Text component, and open the quick selection State menu.
- 4.In the label field, input the environment variable in the following format:
{{env.name}}
.Note: When you reference an environment variable in your app, ensure you replacename
with the variable name you configured in the Environment Variables Configuration window. - 5.To test your variable in the Development environment, you can:
- Navigate to the Logic view's Preview panel and refresh the page.
- Click the play icon to preview the application in a new tab.
Note: To test your variable in the Staging or Production environment, you must first deploy your app to the corresponding environment. For more information, see Deploy your app.