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

# Installation

> Add the Primer Checkout React Native SDK to your app.

> [!WARNING]
>
> 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](https://primer.io/docs/checkout/client-session.md)

> [!NOTE]
>
> 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:

```bash theme={"dark"}
yarn add --exact @primer-io/react-native@3.0.0-beta.1
```

Or with npm:

```bash theme={"dark"}
npm install --save-exact @primer-io/react-native@3.0.0-beta.1
```

> [!NOTE]
>
> 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:

| Platform | Native SDK | Version |
| - | - | - |
| iOS | `PrimerSDK` | `3.0.0-beta.4` |
| Android | `io.primer:android` | `3.0.0-beta.6` |

### iOS

Install the pods from your app's `ios` folder:

```bash theme={"dark"}
cd ios && pod install
```

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.

> [!TIP]
>
> 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](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/guides/native-setup.md).

## Basic usage

Fetch a client token, mount `PrimerCheckoutProvider` with it, and render `PrimerCheckoutSheet` inside:

```tsx theme={"dark"}
import { useState } from 'react';
import { Button } from 'react-native';
import { PrimerCheckoutProvider, PrimerCheckoutSheet } from '@primer-io/react-native';

export function CheckoutScreen({ fetchClientToken }: { fetchClientToken: () => Promise<string> }) {
  const [clientToken, setClientToken] = useState<string | null>(null);
  const [visible, setVisible] = useState(false);

  const openCheckout = async () => {
    setClientToken(await fetchClientToken());
    setVisible(true);
  };

  return (
    <>
      <Button title="Checkout" onPress={openCheckout} />
      {clientToken !== null && (
        <PrimerCheckoutProvider
          clientToken={clientToken}
          onCheckoutComplete={(checkoutData) => {
            console.log('Checkout complete', checkoutData.payment?.id);
          }}
          onError={(error) => {
            console.warn('Checkout error', error.errorId, error.diagnosticsId);
          }}
        >
          <PrimerCheckoutSheet
            visible={visible}
            onRequestDismiss={() => setVisible(false)}
            onDismiss={() => setClientToken(null)}
          />
        </PrimerCheckoutProvider>
      )}
    </>
  );
}
```

* `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](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/guides/handle-payment-result.md).

## Verify the installation

Build and run the app on both platforms:

```bash theme={"dark"}
npx react-native run-ios
npx react-native run-android
```

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](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/troubleshooting.md).

## See also

> [card] [Native setup](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/guides/native-setup.md)
>
> URL schemes, Apple Pay, Google Pay and optional native dependencies

> [card] [Handle the payment result](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/guides/handle-payment-result.md)
>
> Read the outcome of each payment attempt

> [card] [API reference](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/overview.md)
>
> The provider, the sheet, and the hooks

> [card] [Troubleshooting](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/troubleshooting.md)
>
> Fix installation and build issues


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