βΉοΈ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.
For platform detection (iOS, Android, or web), see Browser Info instead.
Prerequisites
This feature is available in all plans. See all plans
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).
To ensure you are using the most up-to-date version, check the Natively GitHub releases page for the latest version number.
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
Refresh App Info action is called automatically on element load, so device information is available as soon as the element initializes. Avoid adding multiple Natively - Device elements on the same page, as each one sends a request to the device on load.
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.
AI-powered editors like Lovable, Base44, and Replit use the JavaScript SDK to implement Natively features.
Copy the relevant line below and paste it into your AI agent.
Device Info
Replace the placeholder at the beginning with a description of what you want to build - for example: "When the app loads, get the device info and display the OS name and app version on the settings page".
Error Handler
Replace the placeholder at the beginning with a description of what you want to build - for example: "Handle HTTP errors silently without showing the native error screen, and display a custom error message instead".
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
getAppInfo() returns empty or undefined values
Make sure the call is made after the SDK has fully loaded. Call it inside nativelyOnLoad() or trigger it from a user interaction rather than immediately on page load.
app_state is not firing
The app_state listener needs to be registered after the SDK is loaded. Register it inside nativelyOnLoad() to ensure it's active before any state changes occur.
Orientation is not updating on device rotation
getAppInfo() returns a snapshot of the orientation at the time of the call - it does not update automatically. Call getAppInfo() again inside your app_state callback when the app returns to the foreground to get the latest orientation value.
Keyboard visibility events are not firing
Keyboard visibility is reported through the separate keyboard_visibility method, not app_state. Make sure you've registered a callback with info.keyboard_visibility(callback) and that it's called after the SDK has loaded.
Error Handler is not suppressing the native error screen
Make sure window.natively.setErrorHandler() is called before any HTTP requests are made. Place it in a Reusable Element that loads on every page so it's always active. If it's only called on specific pages, the error screen will still appear on pages where it hasn't been set.
Last updated