Skip to main content
Primer Checkout React Native SDK is currently in beta (v3.0.0-beta.1). The API is subject to change before the stable release.
Install the @primer-io/react-native package, then wrap your checkout in PrimerCheckoutProvider with a client token. The package brings the native iOS and Android SDKs with it.

Prerequisites

  • A React Native app with its ios and android projects, which you build with Xcode and Gradle
  • iOS deployment target 15.1 or higher
  • Android minSdkVersion 24 or higher
  • CocoaPods, to install the iOS dependencies
  • A client token from your server, created with the Client Session API
This release is built in CI against React Native 0.81.1, 0.82.1 and 0.83.1. The example app runs React Native 0.81 with the New Architecture enabled.

Install the package

Add the package with the exact beta version:
Or with npm:
This is a beta release line. Check that package.json lists 3.0.0-beta.1 with no ^ or ~ in front, so a new beta doesn’t change your build until you upgrade on purpose.
This release uses these native SDKs. They come with the package, so you don’t add them yourself:

iOS

Install the pods from your app’s ios folder:
The package’s .podspec file pins PrimerSDK. Don’t add a pod 'PrimerSDK' line with another version to your Podfile. Set your app’s deployment target to iOS 15.1 or higher.

Android

React Native links the package automatically. It depends on io.primer:android, io.primer:components-analytics and io.primer:components-bridge, all at the version above. Don’t add these artifacts to your app’s build.gradle or force another version of them. Set minSdkVersion to 24 or higher in android/build.gradle. The native Android SDK requires API level 24.

Rebuild the app

The package contains native code. Rebuild and reinstall the app on each platform after you install or upgrade it. Reloading the JavaScript bundle doesn’t load new native code.
Some payment methods need more native setup: URL schemes, Apple Pay, Google Pay, and extra dependencies for 3D Secure, Klarna and Stripe ACH. See Native setup.

Basic usage

Fetch a client token, mount PrimerCheckoutProvider with it, and render PrimerCheckoutSheet inside:
  • PrimerCheckoutProvider starts a checkout session for its clientToken and ends it when it unmounts.
  • PrimerCheckoutSheet opens when visible is true. It closes only when your onRequestDismiss sets visible to false.
  • onDismiss runs after the sheet has closed. Unmounting the provider there means the next checkout starts with a new client token.
To react to the result of each payment, read usePrimerCheckout().paymentOutcome. See Handle the payment result.

Verify the installation

Build and run the app on both platforms:
The package loads its native module as soon as you import it. If the app starts and the import doesn’t throw, the SDK is installed. If it throws, see Troubleshooting.

See also

Native setup

URL schemes, Apple Pay, Google Pay and optional native dependencies

Handle the payment result

Read the outcome of each payment attempt

API reference

The provider, the sheet, and the hooks

Troubleshooting

Fix installation and build issues