react-native-branch is the official React Native SDK for Branch Metrics, a comprehensive mobile linking and attribution platform. It enables developers to integrate deep linking, deferred deep linking, mobile attribution, and analytics into their React Native applications, supporting both iOS and Android platforms. The current stable version is 6.9.0, with frequent updates (typically monthly or bi-monthly) to align with native Branch SDK releases and to expose new methods for compliance and functionality. Key differentiators include its robust deep linking capabilities across platforms, detailed attribution analytics for marketing campaigns, and features like Universal Links and App Links for seamless user experiences. It abstracts much of the underlying native SDK complexity, providing a unified JavaScript interface.
npm install react-native-branchVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the Branch SDK, subscribe to deep link events, and create/log a Branch Universal Object and custom event.
Review the official Branch React Native SDK documentation for specific version migration steps. Typically involves updating native config files, removing duplicate native SDK installations (e.g., from Podfile if already embedded by NPM), and adjusting import statements in native code.
Ensure `Associated Domains` are correctly configured in Xcode, `Info.plist` has `branch_universal_link_domains` and URL Schemes, and `AndroidManifest.xml` includes `intent-filters` for your Branch domains and `BranchKey`. Also, check if `deferInitForPluginRuntime: true` is set in `branch.json` for cold start deep link reliability, and call `RNBranchModule.initSession` in `MainActivity.java`/`.kt` and `AppDelegate.mm`/`.swift`.
Remove any calls to `branch.setDebug()`. Refer to the latest Branch SDK documentation for current debugging practices, which often involve setting log levels or flags in `branch.json` or native configuration.
For Expo managed apps, consider using `@config-plugins/react-native-branch` which attempts to inject necessary configurations. However, for full control and all Branch features, converting to an Expo Bare Workflow or using a custom development client might be necessary. Alternatively, evaluate if simpler deep linking solutions like `expo-linking` suffice.
Ensure that native Branch SDKs are *not* manually added via `build.gradle` or `Podfile` if using `react-native-branch` v2.0.0 or later. The NPM module embeds the native SDKs. Remove `pod 'Branch-SDK'` from your Podfile if it's there.
Verify that your `linking` configuration in `React Navigation` (e.g., in your root navigator) accurately defines the paths and screens that correspond to the data you expect from Branch deep links. Use `branch.subscribe` to get params and debug the expected navigation structure.
If using `react-native-branch` version 2.0.0 or newer, remove any manual `pod 'Branch-SDK'` or `pod 'Branch'` entries from your `Podfile`. The React Native module handles native SDK inclusion automatically. Run `pod install --repo-update` after modifying your Podfile.
Increase your project's `minSdkVersion` in `android/app/build.gradle` to match or exceed the requirement of `react-native-branch`. For modern React Native apps, a `minSdkVersion` of 21 or higher is generally recommended. Update to `minSdkVersion = 21` (or higher) in `defaultConfig` block.
Try importing `branch` as a named export: `import { branch } from 'react-native-branch';`. If that doesn't work, refer to the specific version's documentation or use `import * as branch from 'react-native-branch';` for older CJS-like modules. The current official documentation implies `import branch from 'react-native-branch'` is correct.