App Variables
App Variables are shared pieces of data that live at the app-level and can be set and used across your entire app. They are useful for storing data that is common to all users or different parts of your UI. App Variables can be set to any valid JSON and you can access App Variables from anywhere in your app.
Each time your App restarts, the App Variable will reset to the default value. That means you shouldn’t store information that needs to persist across app launches - use a Device Variable instead.
For example, you might have a variable named error_message that you can set and access across all Screens in your app to display an error message in a Text component. Or use it to store the state of a Modal.
Creating an App Variable
Section titled “Creating an App Variable”To create variables, open the Variables modal from the left menu bar of the Builder.
Configuration
Section titled “Configuration”| Parameter | Description |
|---|---|
| Name | The name of the variable to be referenced. |
| Development Value | The default value when building and publishing using the Development Environment |
| Production Value | The default value when building and publishing using the Production Environment |
Updating an App Variable
Section titled “Updating an App Variable”Set Variable Action
Section titled “Set Variable Action”To update the value of an App Variable, you will use the Set Variable Action from a Trigger in the Interactions tab from the right panel of the Builder.
In Custom Code
Section titled “In Custom Code”You can also work with App Variables in Files and Functions. Learn how in the Variables with Custom Code doc.