> For the complete documentation index, see [llms.txt](https://docs.buildnatively.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.buildnatively.com/guides/integration/browser-info.md).

# Browser Info

## What is Browser Info?

Browser Info gives your app access to two types of information: the environment it's running in, and the device's current network status. You can use it to detect whether the user is inside a Natively iOS app, a Natively Android app, or a regular web browser - and conditionally show or hide features based on that. You can also listen for connectivity changes to handle offline states gracefully.

## Prerequisites

{% hint style="success" %}
This feature is available in all plans. [See all plans](/getting-started/subscription-plans.md)
{% endhint %}

## 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

{% tabs %}
{% tab title="Bubble.io Plugin" %}
**Check Plugin**

Before starting, verify if the Natively plugin is already installed in your Bubble project.

1. Open your Bubble editor and navigate to the Plugins tab in the left sidebar.
2. **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.

<figure><img src="https://docs.buildnatively.com/~gitbook/image?url=https%3A%2F%2F3352617162-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F90tV7pYflEQdiAr2VfWu%252Fuploads%252FmfnSUug82IdnxOAoBrak%252Fnatively_app_builder_bubble_plugin_update.png%3Falt%3Dmedia%26token%3Dc193f69f-b03b-4be4-b80b-f34ba37ac212&#x26;width=768&#x26;dpr=3&#x26;quality=100&#x26;sign=a89e4510&#x26;sv=2" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://docs.buildnatively.com/~gitbook/image?url=https%3A%2F%2F3352617162-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F90tV7pYflEQdiAr2VfWu%252Fuploads%252FC5rA42yQHcN1uGKFbzmF%252Fnatively_app_builder_bubble_plugin.png%3Falt%3Dmedia%26token%3Dd9706d9b-dbe8-459b-b9b3-5667648aa4b7&#x26;width=768&#x26;dpr=3&#x26;quality=100&#x26;sign=9aae2297&#x26;sv=2" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="JavaScript SDK" %}
**Check SDK**

Before writing any logic, ensure the Natively SDK is correctly installed and up-to-date in your codebase.

1. Open your project's main HTML file (or header settings) and look for the Natively script tag inside the `<head>` section.
2. Install/Update: If missing or outdated, add the following code. You can specify the SDK version in the URL (e.g., `@2.26.0`).

```javascript
<head>
  <script async onload="nativelyOnLoad()" src="https://cdn.jsdelivr.net/npm/natively@2.26.0/natively-frontend.min.js"></script>
</head>
```

{% hint style="info" %}
To ensure you are using the most up-to-date version, check the [Natively GitHub releases page](https://github.com/buildnatively/js-sdk/releases) for the latest version number.
{% endhint %}
{% endtab %}

{% tab title="AI Agents" %}
**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.

```
Check if the following Natively SDK script is present in the <head> of index.html. If missing or outdated, add it: <script async onload="nativelyOnLoad()" src="https://cdn.jsdelivr.net/npm/natively@2.26.0/natively-frontend.min.js"></script><script>function nativelyOnLoad() { window.natively.setDebug(true); console.log("✅ Natively SDK loaded successfully."); }</script> For reference: https://docs.buildnatively.com/guides/integration/how-to-get-started https://github.com/buildnatively/js-sdk/releases
```

{% endtab %}
{% endtabs %}

### Setup Logic

{% tabs %}
{% tab title="Bubble.io Plugin" %}

### \[Element] Natively - Browser

#### Events:

* **Device went offline** - fires when the device loses internet connectivity.
* **Device back online** - fires when the device regains internet connectivity.

#### States:

* **isAndroidApp** - Yes / No.
* **isIOSApp** - Yes / No.
* **isNativeApp** - Yes / No.
* **Connectivity** - Yes / No (Device is online or offline).
  {% endtab %}

{% tab title="JavaScript SDK" %}

```javascript
// ============================================================================
// NATIVELY BROWSER INFO - DOCUMENTATION & EXAMPLES
// ============================================================================

// Initialize
const info = new NativelyInfo();

// ============================================================================
// ALL AVAILABLE METHODS
// ============================================================================
// info.browserInfo()
//   - Returns information about the current app environment.
//   - Returns an object synchronously — no callback required.
//
// Response fields:
// browserInfo.isAndroidApp  - Boolean. true if running as a Natively Android app.
// browserInfo.isIOSApp      - Boolean. true if running as a Natively iOS app.
// browserInfo.isNativeApp   - Boolean. true if running as either a Natively iOS or Android app.

// ============================================================================
// CONNECTIVITY EVENTS
// ============================================================================
// window.ononline  - Fires when the device regains internet connectivity.
// window.onoffline - Fires when the device loses internet connectivity.

// --- Browser Info. Environment Detection Example. Start ---

const browserInfo = info.browserInfo();

console.log("Is Android app:", browserInfo.isAndroidApp);
console.log("Is iOS app:", browserInfo.isIOSApp);
console.log("Is native app:", browserInfo.isNativeApp);

// --- Browser Info. Environment Detection Example. End ---


// --- Browser Info. Connectivity Example. Start ---

window.ononline = function() {
    console.log("Device is online");
};

window.onoffline = function() {
    console.log("Device is offline");
};

// --- Browser Info. Connectivity Example. End ---
```

{% endtab %}

{% tab title="AI Agents" %}
AI-powered editors like Lovable, Base44, and Replit use the JavaScript SDK to implement Natively features.&#x20;

Copy the line below and paste it into your AI agent.&#x20;

<pre><code>[<a data-footnote-ref href="#user-content-fn-1">Your feature description</a>] using the Natively Browser Info SDK: const info = new NativelyInfo(); const browserInfo = info.browserInfo(); // browserInfo.isAndroidApp — true if running as a Natively Android app. // browserInfo.isIOSApp — true if running as a Natively iOS app. // browserInfo.isNativeApp — true if running as either iOS or Android Natively app. // Connectivity: window.ononline = function() { /* device is online */ }; window.onoffline = function() { /* device is offline */ }; For reference: https://docs.buildnatively.com/guides/integration/browser-info
</code></pre>

{% hint style="warning" %}
Replace the placeholder at the beginning with a description of what you want to build - for example: "Show the Sign in with Apple button only when the app is running on iOS, and hide it on Android and web browsers".
{% endhint %}
{% endtab %}
{% endtabs %}

### How to use

#### Conditional feature visibility

The most common use case is showing or hiding features based on the platform. Use `browserInfo.isIOSApp` and `browserInfo.isAndroidApp` to conditionally render platform-specific elements - for example, showing the Sign in with Apple button only on iOS, or displaying an Android-specific payment method only on Android.

#### Detecting the web context

If `browserInfo.isNativeApp` is `false`, the user is accessing your app from a regular web browser, not a Natively app. You can use this to show a prompt encouraging them to download the mobile app, or to disable features that only work in a native context.

#### Handling offline states

Use `window.ononline` and `window.onoffline` to respond to connectivity changes in real time. Common use cases include showing an offline banner, disabling form submissions when offline, or queuing actions to retry once the connection is restored.

#### Call browserInfo early

Since `info.browserInfo()` returns synchronously without a callback, call it as early as possible in your app's initialization - ideally right after the Natively SDK loads in `nativelyOnLoad()`. This ensures platform detection is available before any conditional rendering happens.

## Troubleshooting

<details>

<summary><code>browserInfo</code> values are all <code>false</code> in a web browser</summary>

This is expected behavior - `isIOSApp`, `isAndroidApp`, and `isNativeApp` are all `false` when the app is accessed from a regular web browser. Design your logic to handle this case gracefully.

</details>

<details>

<summary><code>window.ononline</code> / <code>window.onoffline</code> not firing</summary>

These are standard browser events and should work in the Natively app. If they are not firing, verify that the SDK is fully loaded before attaching the event listeners - attach them inside `nativelyOnLoad()` to ensure the environment is ready.

</details>

<details>

<summary>Platform detection runs before the SDK loads</summary>

If you call `info.browserInfo()` before the Natively SDK has finished loading, the values may be incorrect. Always call it inside `nativelyOnLoad()` or after confirming the SDK is initialized.

</details>

[^1]: Replace this placeholder
