Skip to main content

Overview

SDK Updates
New versions of the SDK are released frequently, not only to add new features and address issues in the SDK, but also to continuously improve the conversion of merchant login flows. As a result, we strongly recommend that you frequently update your SDK version across any platforms where you invoke the SDK.
The Knot Link SDK provides a seamless way for end users to link their merchant accounts to your React Native app, serving as the foundation for Knot’s merchant connectivity platform. It is a client-side integration, consisting of initializing & configuring the SDK and handling events.
Upgrading from 2.x? Follow the 3.0.0 migration guide.

Requirements

  • React Native 0.76 or higher, on the old or the New Architecture (0.82 and later have only the New Architecture). On React Native 0.73–0.75, stay on 2.x. See Staying on 2.x.
  • iOS 15.1 or higher (the minimum of React Native 0.76). Installed via CocoaPods (pod install, the default) or React Native’s Swift Package Manager mode (React Native 0.87+, experimental). See iOS.
  • Android minSdkVersion 24 or higher, JDK 17 to build, and Maven Central reachable from your app’s Gradle repositories (the native Knot Android SDK is published there). See Android.
  • Expo: development builds / prebuild are supported. The managed workflow (Expo Go) is not, because the SDK ships native code.
  • Not supported: Mac Catalyst and visionOS. The bundled KnotAPI.xcframework has only iOS device and simulator slices.

Installation

You can install the Knot SDK using npm or yarn in your react-native project directory, like below:
Autolinking adds the native module to your iOS and Android projects. iOS needs one more step, below.

iOS

The Knot native iOS SDK (KnotAPI.xcframework) ships inside the react-native-knotapi npm package starting with version 2.3.0. Nothing is fetched from the CocoaPods trunk, so the CocoaPods trunk going read-only on December 2, 2026 does not affect either install path below. Earlier versions resolve the KnotAPI pod from the CocoaPods trunk; upgrade to 2.3.0 or later.

CocoaPods (default)

Shell
Then rebuild the app. The module’s podspec vendors the native SDK, so no KnotAPI pod is added to your Podfile.lock. If you are upgrading from an earlier version, the KnotAPI pod is removed from your Podfile.lock on the next pod install; that is expected. A build-time warning is printed when the bundled native SDK is outdated. Set KNOT_SDK_VERSION_WARNING_DISABLED=1 in the build environment to silence it.

Swift Package Manager (React Native 0.87+, experimental)

React Native 0.87 added an opt-in SwiftPM mode that replaces CocoaPods for the whole app. react-native-knotapi ships a Package.swift, so it is autolinked there with no extra configuration:
Shell
After that, install or remove native packages and build; React Native re-runs autolinking on build. After a fresh clone or in CI, run npx react-native spm once before building (the SwiftPM analog of pod install). npx react-native spm deinit followed by pod install restores CocoaPods.
React Native still describes this mode as experimental and not for production use; CocoaPods remains the default and supported path. The outdated-SDK build warning is CocoaPods-only.
Other native dependencies in your app that ship no Package.swift make npx react-native spm exit with Package.swift is missing for library ...; React Native’s answer is npx react-native spm scaffold followed by npx patch-package <dep> to commit the result.

Android

Android uses autolinking. Make sure your app declares the internet permission in android/app/src/main/AndroidManifest.xml (present by default in most React Native apps):
AndroidManifest.xml
Knot publishes the native Knot Android SDK (com.knotapi.knot:knotapi-android-sdk) on Maven Central. react-native-knotapi declares no Gradle repositories of its own, so your app’s build has to make Maven Central reachable:
  • Apps that apply the React Native Gradle plugin (apply plugin: "com.facebook.react" in android/app/build.gradle, as every React Native template does) get it automatically: the plugin adds mavenCentral() to every project.
  • If you set the plugin’s exclusiveEnterpriseRepository property (newer React Native versions; 0.76 doesn’t have it), the plugin replaces all repositories with that proxy. Make sure the proxy mirrors Maven Central.
  • If your build declares repositories in settings.gradle (dependencyResolutionManagement), include mavenCentral() there.
Otherwise Gradle can’t resolve com.knotapi.knot:knotapi-android-sdk. On the New Architecture, an Android host has to build React Native’s appmodules library. Only the React Native Gradle plugin builds it, so apply com.facebook.react to the app, or to a library module packaged as an AAR for a native host. See Android hosts without com.facebook.react.

Usage

Import methods like the below:

Initialization

Your backend will create a session by calling Create Session and provide it to your frontend. To start a Knot session, you must first pass a configuration object to Knot.open. The configuration allows you to set the environment, entry point, and other user experience configurations.
It’s expected that your integration with Knot will retrieve and pass a new session into the SDK on each initialization.

Configure the session

The SDK is configured using the following parameters inside the open method:

CustomerConfiguration

This class is entirely optional and infrequently used, typically only when you offer Knot for multiple, differently-named card programs in the same app. The Knot team will set pre-defined values of your choosing for each parameter that you can then subsequently pass into the SDK. Passing a value that is not pre-defined will result in an onError callback. To take advantage of this functionality, please contact the Knot team who will be happy to assist you.
See the following examples for how the parameters are used together in text inside the Knot SDK: "Your [customerName] [cardName | card] was added."

Open the session

To begin the flow, use the open method like below:
To test logging in to a merchant in the SDK, please reference a set of available test credentials for the CardSwitcher product here and the TransactionLink product here.

Single merchant flow

You may decide to use List Merchants to retrieve a list of merchants, list them in your app, and then open the SDK with a single merchant. To do so, pass a merchant ID in merchantIds when configuring the session. More in Retrieving & Listing Merchants. The merchant ID is the same across all environments.
Although available, we do not recommend that you provide a long list of merchants in order to remove a few, but rather “hide” certain merchants that you desire from your Knot Dashboard.

Entry points

In your app’s user experience, you may choose to integrate Knot in one or multiple places (e.g. from different tabs or screens). How users behave when interacting with Knot from each of these “entry points” may vary. It will be useful for you to be able to differentiate these groups of users by entry point in order to assess the value of each entry point. You can provide a value for the entry point when configuring the session in Knot.open. This value will be returned in the AUTHENTICATED webhook. Users are presented with a list of merchants in the SDK (unless you provide a single merchant as described above). Accompanying the list is a set of categories and a search experience. Search is shown by default (useSearch defaults to true). Categories are shown when you set useCategories: true (it defaults to false), which we recommend. You can remove search by setting useSearch: false in Knot.open. This is not recommended.

Events

To receive updates from the SDK, implement the addKnotListener method.
The provided TypeScript types can be found below:
TypeScript
The Transaction Link product is spelled differently on the way in and out: Knot.open takes product: 'transactions_link', and events report product: 'transaction_link'.

onSuccess

This event is called when a user successfully logged in to the merchant and their card was switched. It receives a KnotSuccess, whose merchant is the name of the merchant.

onError

This event is called when an error occurs during SDK initialization and emits a KnotError with the following errors: knot:onExit follows INVALID_PARAMS and Activity_Not_Found, unless a Knot flow is already open. In that case, the open flow carries on and ends with its own knot:onExit. The other error codes come from the Knot native SDKs.
Sessions are valid for 30 minutes. If a session expires while the SDK is open, the SDK will emit an expired session error via onError and automatically close. To provide a seamless experience, handle the REFRESH_SESSION_REQUEST event via the onEvent callback to proactively extend the session using Extend Session before expiration occurs.

onExit

This event is called when a user closes the SDK.

onEvent

This event is called when certain events occur in the SDK. With this callback, you will be able to understand how a user is progressing through their lifecycle of authenticating to a merchant. The following list contains all possible events emitted in the KnotEvent.event property:

Other options

Open without delay

Knot.open opens the Knot UI on the next tick (setImmediate), so it doesn’t block the current touch handler. Knot.openWithoutDelay takes the same config and opens immediately. Use it only if the deferred open causes a visible delay in your flow.
JavaScript

Reloads and React hosts

Reloads. If the JS bundle reloads while the Knot UI is open (a dev reload, or an OTA update restart such as expo-updates’ reloadAsync), react-native-knotapi closes the Knot UI. That flow sends no further events, including knot:onExit, to the reloaded JS. Open a new session from the reloaded app if needed. On Android, a dev reload (Metro, DevSettings.reload()) can’t happen while the Knot UI is open: React Native turns dev support off while another Activity is in front. An OTA restart reloads as usual. One React host. react-native-knotapi supports one React Native host per process. If an app runs more than one, the Knot UI’s events go to the host whose Knot.open last opened it, and Knot.close() from any host closes the Knot UI. A Knot.open that fails with knot:onError before the UI opens (invalid config, or on Android no current Activity) doesn’t count. A reload of a host closes the Knot UI only while a flow that host opened is still up: its Knot.open was the last to open the UI, and that flow hasn’t ended.

Get current SDK version

If you need to retrieve the current SDK version for your own use case, implement the following:
JavaScript

Close the SDK

If you need to explicitly close the SDK, use the below method, otherwise end users will naturally close the SDK as they interact with the interface.
JavaScript

Maintain cookies

Android only.
Knot clears cookies for security purposes. If your app relies on cookies, you can allowlist specific domains using the domainUrls configuration in Knot.open. This is uncommon.
JavaScript

Testing with Jest

The package ships a Jest mock. Use it in a test file or your Jest setup file:
JavaScript
Knot.* and addKnotListener are then jest.fn()s, so you can assert on them, for example expect(Knot.open).toHaveBeenCalled(). A 2.x mock of NativeModules.Knotapi through jest.mock('react-native', …) may no longer reach the module in 3.x. See Jest mocks.

Staying on 2.x

If you can’t move to React Native 0.76 or iOS 15.1 yet, stay on 2.x:
From 3.0.0 on, latest points at 3.x and legacy-2x at the newest 2.x release. 2.x needs React Native 0.73 or later and iOS 14.0 or later. See the 2.3.0 README on npm.