Env (Environment)
Env (Environment)
Get an environment variable
var appId = Fliplet.Env.get('appId');
These variables are usually available on app screens as long as components and providers:
apiUrl
- the base URL of Fliplet APIs (e.g.https://api.fliplet.com/
)appFonts
- array of fonts uploaded for the current appappHooks
- array of security hooks that have been set up the current appappId
- the current app idappName
- the current app nameappPages
- array of pages for the current appappSettings
- object with public settings for the current appappSlug
- string with the public slug (URI) for the current appappUpdatedAt
- timestamp set to the last time a change has been made via Fliplet Studio to the current appappVersion
- number pointing to the app’s version (when using Fliplet Viewer, its value will be(DEV)
)appTemplate
- boolean indicating whether the app is a templateappsUrl
- the base URL for Fliplet Apps (e.g.https://apps.fliplet.com/
)development
-true / false
true when if developing via the Fliplet CLIinteract
-true / false
true when you are in edit mode in Fliplet StudiomasterAppId
- when called from a live app, returns the ID of the master app seen through Fliplet Studiomode
interact
: The app is running in Fliplet Studio while in edit modepreview
: The app is running in Fliplet Viewer or in Fliplet Studio while in preview modeview
: The app is running in a live environment (e.g. web app or from an app distributed via App Store / Google Play / MDM)
demo
- boolean indicating whether the app is running in demo mode (e.g. when browsed via app previews)organizationName
- the user’s organization nameorganizationId
- the user’s organization idpageId
- the current page idpageMasterId
- when called from a live app, returns the ID of the master page seen through Fliplet StudiopageTitle
- the current page (screen) titlepageSettings
- object with public settings for the current pageplatform
- either'web'
or'native'
(use Fliplet.Env.is for easier checks)provider
-true / false
whether the current component (widget) is running in provider modepreview
-true / false
true when you are in edit or preview mode in Fliplet Studiouser
- the current user
Set an environment variable
Through the set()
method you can overwrite any of the above environment variables at runtime or add new ones. Please note that they will only be available until the screen navigates away to a new screen.
Fliplet.Env.set('appId', 2);
Check the current app’s environment (platform)
Use the is()
method to check whether the current app is running in a native
(e.g. iOS and Android devices) or web
environment.
if (Fliplet.Env.is('native')) {
// this code will run on native devices (iOS and Android) only
}
if (Fliplet.Env.is('web')) {
// this code will run on desktop browsers only
}