ℹ️Device Info
Access details about the user's device, app, and runtime environment.
What is Device Info?
Device Info gives your app access to details about the user's device and your app's runtime environment - device model, OS version, app build info, dark mode status, and screen orientation. It also lets you listen for app state changes (foreground/background) and keyboard visibility, and includes an error handler for managing HTTP request failures without showing the default error screen.
Prerequisites
Implementation
Choose your integration method below: Bubble.io Plugin (No-Code), JavaScript SDK (Code), or AI Agents (for AI-powered editors like Lovable, Base44, and Replit).
Initialization
Check Plugin
Before starting, verify if the Natively plugin is already installed in your Bubble project.
Open your Bubble editor and navigate to the Plugins tab in the left sidebar.
Check Installed Plugins: Look through your list of installed plugins for "Natively iOS & Android app builder".
If it IS installed: Check the version number. If an update is available (e.g., you see a button saying "Update"), click it to ensure you have the latest features and bug fixes.

If it is NOT installed: Click the + Add plugins button, search for "Natively", and click Install.

Check SDK
Before writing any logic, ensure the Natively SDK is correctly installed and up-to-date in your codebase.
Open your project's main HTML file (or header settings) and look for the Natively script tag inside the
<head>section.Install/Update: If missing or outdated, add the following code. You can specify the SDK version in the URL (e.g.,
@2.26.0).
Initialize the SDK
AI-powered editors like Lovable, Base44, and Replit use the JavaScript SDK to implement Natively features. Before implementing any feature, the Natively SDK must be initialized in your project.
Copy the line below and paste it into your AI agent to check and set up the Natively SDK in your project.
Setup Logic
[Element] Natively - Device
Events:
App Info received - fires when device and app information is successfully retrieved.
App went foreground - fires when the user opens the app.
App went background - fires when the user minimizes the app without exiting.
Keyboard is visible - fires when the on-screen keyboard appears.
Keyboard is hidden - fires when the on-screen keyboard is dismissed.
Error occurred - fires when an HTTP request fails, and the Set Error Handler action has been previously called on the current page. (Available starting from v. 2.26.0)
States:
Device - device model identifier. (iOS values can be decoded with this list)
OS Version - Android / iOS version.
App Version - your app's build version.
Build Number - your app's build number.
Natively SDK Version - the Natively SDK version in use.
OS Name - "Android" or "iOS".
isDarkMode - Yes / No.
Orientation - "PORTRAIT" or "LANDSCAPE".
Error Code - the HTTP status code of the failed request (e.g. 404, 500).
Error Description - a text description of the error provided by the requester endpoint.
Error Response Data - the raw response body (JSON/Text) returned by the server for the failed HTTP request (if available).
Actions:
Refresh App Info - retrieves the latest device and app information.
Set Error Handler - enables custom error handling for the current page session. When active, the app will not automatically display the native error screen when an HTTP request fails. Instead, it fires the Error occurred event.
How to use the Error Handler
To ensure consistent error handling across your app, place the logic in a Reusable Element (like your Header or a dedicated technical Reusable) that exists on every page.
Place the Natively - Device element inside your Reusable Element.
When Natively - Device's Device state is not empty (this ensures the element is fully initialized) > call the Set Error Handler action.

Create a workflow to handle the error when it happens (the event Error occurred is fired).

The error's details can also be visible in the Debug console.
How to use
Reading device info on app load
Call info.getAppInfo() early in your app's initialization, ideally inside nativelyOnLoad(), so device details are available before any conditional logic runs. Store the result rather than calling it repeatedly.
Detect dark mode
Use resp.isDarkMode to apply the correct theme when the app loads. Combine with app_state to re-check when the user returns to the foreground, since they may have changed their system appearance while the app was backgrounded.
Handle orientation changes
Use resp.orientation from getAppInfo() to adjust your layout on load. Note that this is a snapshot at the time of the call - it won't update automatically as the device rotates. Call getAppInfo() again inside app_state if you need to track rotation.
App state: foreground and background
Use resp.state inside app_state to pause or resume activity when the user switches apps. Common use cases include pausing media playback, stopping timers, or refreshing data when the user returns.
Keyboard visibility
Use resp.visible inside keyboard_visibility to adjust your layout when the keyboard appears or disappears - for example, scrolling to a focused input or hiding a bottom navigation bar.
Error Handler - when to use it
Enable the Error Handler when you want to handle HTTP failures gracefully instead of showing the native error screen. Place it in a Reusable Element that exists on every page so it's always active. Use resp.type to distinguish between network failures (NETWORK_ERROR) and server errors (HTTP_ERROR), and resp.code to respond differently to specific status codes like 401 or 500.
Troubleshooting
Last updated