The Draftbit Docs

Welcome to the Draftbit documentation. You'll find comprehensive documentation and information to help you start working with Draftbit as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Global Variables

Global Variables in Draftbit apps are categorized in two different type of variables:

  • App Variables
  • Device Variables

App Variables

In the App Variables menu, you can save API tokens to be used for any REST Services & Endpoints that you add to your project. The value for any App Variable is a string.

Saving API authorization in this menu, as opposed to entering it directly inside of a Fetch component, makes your app more secure by preventing your API token(s) from being exposed in each screen's code.

Access the App Variables menu by clicking the 'Settings' button on the left-hand side of the Builder and clicking the 'Global Variables' tab.

App Variables

However, each time your App is restarted, the App Variable will reset to the default value. If you need to change the default value of an App Variable, you must update the value in the builder and re-publish your App.

Device Variables

Device Variable is a special kind of App Variable that are permanently stored on your users' devices. For example, a user's auth token is usually stored as a Device Variable. Device Variables can only be strings. You can optionally set a default value for a Device Variable (if you do not, it will default to an empty string "").

You can access Device Variables anywhere in your app you use data as a Global Variable, and they can be changed with the GlobalVariableContext Custom Code API while your app is running.

However, unlike App Variables, a Device Variable will not reset to the default value the next time the app starts. Rather, it will be the same value it was when the app last closed. Unlike App Variables, re-publishing an app currently has no effect on Device Variables.

Device Variables

Configuration

Parameter

Description

Key

The name of the variable to be referenced

Value

The actual value of the variable (ex. authorization token)

Updated 19 days ago


Global Variables


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.