> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dashlink.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# React Native SDK

> Install the Dashlink React Native wrapper, forward live links, and recover the original content after a store install.

The React Native package calls the [Android](https://docs.dashlink.ai/guides/app-dynamic-links/android.md) and [iOS](https://docs.dashlink.ai/guides/app-dynamic-links/ios.md) SDKs. It does not replace app association. Routing still needs an `autoVerify` intent-filter and an `applinks:` host in the native project.

The package forwards live links and recovers the original destination on first open after a store install, using the native Android and iOS SDKs.

## When you need the SDK

| You have | Use |
| - | - |
| App installed, Dynamic Link host declared, OS verified | The OS delivers the short URL. Forward it to `handleUniversalLink`, or parse it yourself. |
| First open after a store install from a Dynamic Link | Call `getDynamicLink()` at startup. Android reads Play Install Referrer. iOS reads the pasteboard. |
| Later launches | Deferred is not re-run. |

`getDynamicLink()` and `handleUniversalLink(url)` stay split, matching the native SDKs. On Android, `getDynamicLink()` also reads the current activity intent, so a cold start from an App Link is covered there. On iOS, `getDynamicLink()` is only the pasteboard check. A live Universal Link must be passed to `handleUniversalLink`.

## Install

```bash theme={null}
npm install @dashlink/react-native
```

The host app also depends on the native SDKs:

* Android: `implementation("ai.dashlink:dashlink-android:1.0.0")`
* iOS: CocoaPods `pod 'Dashlink', '~> 1.0.0'` (the React Native podspec already declares this)

Register `DashlinkPackage` on Android if autolinking does not pick it up. Rebuild the native app after installing the package.

## Dynamic Link API key

JSON resolve requires a **Dynamic Link** key. REST keys (`dlk_live_`) are rejected.

1. Settings → API Keys → Type **Dynamic Link**.
2. Call `configure` before any resolve.
3. Call `setDynamicLinkHosts` with the Dynamic Link domain. An empty list lets any https URL with a back-half through.

```ts theme={null}
import Dashlink from "@dashlink/react-native";

await Dashlink.configure("dlk_sdk_…");
await Dashlink.setDynamicLinkHosts(["yourbrand.dshl.in"]);
```

## Association

Declare the Dynamic Link host in `AndroidManifest.xml` and in Associated Domains. The wrapper cannot invent OS intercept. See [App association](https://docs.dashlink.ai/guides/app-dynamic-links/app-association.md).

## Live taps

Subscribe to React Native `Linking` and forward every URL.

```ts theme={null}
import { Linking } from "react-native";

async function open(url: string | null) {
  if (!url) return;
  const pending = await Dashlink.handleUniversalLink(url);
  pending?.appUrl; // navigate
}

Linking.getInitialURL().then(open);
Linking.addEventListener("url", (event) => open(event.url));
```

An installed tap JSON-resolves with `deferred=0` and `match=direct`, returns `appUrl`, and analytics records `app_open`.

## Deferred first open

Call `getDynamicLink()` once at startup, after `configure` and `setDynamicLinkHosts`.

```ts theme={null}
const pending = await Dashlink.getDynamicLink();
pending?.appUrl;
pending?.isDeferred;
pending?.clickId;
```

Android reads Play Install Referrer (`match=referrer`). iOS reads the pasteboard (`match=pasteboard`) and may show the system paste banner once. Both publish `deferred_open` joined to the store tap's `click_id`. An empty or foreign value is a miss and is consumed once.

Editor and web bundles have no native module. `configure` throws until the app is rebuilt with the native package linked.

## Tracking

The store redirect is the click. SDK JSON resolve is an outcome on that click when `click_id` matches, not a second campaign click. Fields on the result are `appUrl`, `destinationUrl`, `fallbackUrl`, `clickId`, `isDeferred`, `matchType`, `outcome`, `utmSource`, `utmMedium`, `utmCampaign`, and `shortUrl`.

## Test on a device

**1. Uninstall the app**

A previous install will not re-run deferred recovery.

**2. Tap a Dynamic Link**

The device should reach the store, not the home screen.

**3. Install a build that includes the wrapper**

The host and the API key must already be configured.

**4. Open the app**

First open must land on `appUrl`, and analytics must show `deferred_open` for the same `click_id`.

If an installed tap still opens the browser, the problem is almost always [app association](https://docs.dashlink.ai/guides/app-dynamic-links/app-association.md), not the wrapper.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.