Device Variables

Store persistent data on the user's device

Device Variable is a special kind of variable that is permanently stored on your users' devices using AsyncStorage from React Native. Device Variables can be set to any valid JSON and you can access Device Variables from anywhere in your app.

A Device Variable will not reset to the default value the next time the app starts. Instead, it will be the same value when the app is last closed. Use an App or Screen Variable to store ephemeral data.

For example, you might have a Device Variable named auth_token where you store a user's authentication token for making API requests. Storing this data in a Device Variable will ensure that the value persists across app launches.

⚠️

Republish after updating default values

If you need to change the default value of an Device Variable for a published app, you'll need to update the value in the Builder and then republish your app.

❗️

Don't set sensitive data as default values

Default values that you set for Device Variables are stored in your app's source code and bundle making it possible for bad actors to access and abuse the data. You should usually never store private data such as API keys as default values in Device Variables.

Creating a Device Variable

To create variables, open the Variables modal from the left menu bar of the Builder.

Configuration

ParameterDescription
NameThe name of the variable to be referenced.
Development ValueThe default value when building and publishing using the Development Environment
Production ValueThe default value when building and publishing using the Production Environment

📘

What type of value can you store in a Device Variable?

All JSON primitive value types can be stored inside a Device Variable. Learn more here.

Updating a Device Variable

Set Variable Action

To update the value of an Device 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

You can also work with App Variables in Files and Functions. Learn how in the Variables with Custom Code doc.