> ## 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.

# Install Primer Checkout

> Package managers, browser requirements and initial setup for Web, iOS, Android and React Native.

## Prerequisites

You'll need your `clientToken` to initialize Primer Checkout. See our [Client Session guide](https://primer.io/docs/checkout/client-session.md) on how to create a client session and retrieve a `clientToken` first.

## Environment Requirements

Before diving into the implementation, ensure your environment meets these requirements:

| Requirement | Details |
| - | - |
| **Node.js** | Current LTS version recommended |
| **Browsers** | Modern browsers with ES2020 support (see below) |
| **Not Supported** | Internet Explorer 11, Classic Edge (legacy) |

### Minimum Browser Versions

The SDK requires ES2020 support. Minimum supported browser versions:

| Browser | Minimum Version |
| - | - |
| Chrome | 80+ |
| Edge | 80+ |
| Firefox | 79+ |
| Safari | 14+ |
| iOS Safari | 14+ |
| Opera | 67+ |
| Samsung Internet | 13.0+ |

> [!NOTE]
>
> Legacy browsers like Internet Explorer 11 aren't officially supported due to their non-standard DOM behavior and lack of support for modern Web Component features and ES2020 syntax that this SDK is built on.

## Install the SDK

> [tab] Web
>
> Install the Primer SDK using your preferred package manager:
>
> > [!NOTE]
> >
> > `@primer-io/primer-js` is installed via a package manager. Pick whichever you use. npm, yarn, and pnpm are all supported.
>
> > [tab] npm
> >
> > ```bash theme={"dark"}
> > npm install @primer-io/primer-js
> > ```
>
> > [tab] yarn
> >
> > ```bash theme={"dark"}
> > yarn add @primer-io/primer-js
> > ```
>
> > [tab] pnpm
> >
> > ```bash theme={"dark"}
> > pnpm add @primer-io/primer-js
> > ```

> [tab] Android
>
> Add the Primer BOM and the Primer Checkout SDK to your module-level `build.gradle.kts`. The BOM keeps the SDK and the 3DS, Klarna and Stripe ACH wrappers on the same version:
>
> ```kotlin theme={"dark"}
> dependencies {
>     implementation(platform("io.primer:bom:3.0.0-beta.8"))
>     implementation("io.primer:checkout")
> }
> ```
>
> Or without the BOM:
>
> ```kotlin theme={"dark"}
> dependencies {
>     implementation("io.primer:checkout:3.0.0-beta.8")
> }
> ```
>
> To add the wrappers, see [Payment method dependencies](https://primer.io/docs/sdk/android-checkout/v3.0.0-beta/installation.md#payment-method-dependencies).
>
> Ensure Jetpack Compose is enabled in your module-level `build.gradle.kts`:
>
> ```kotlin theme={"dark"}
> android {
>     buildFeatures {
>         compose = true
>     }
>     composeOptions {
>         kotlinCompilerExtensionVersion = "1.5.8"
>     }
> }
>
> dependencies {
>     implementation(platform("androidx.compose:compose-bom:2025.12.00"))
>     implementation("androidx.compose.ui:ui")
>     implementation("androidx.compose.material3:material3")
>     implementation("androidx.lifecycle:lifecycle-runtime-compose:2.7.0")
> }
> ```
>
> > [!WARNING]
> >
> > **This is a beta SDK.** The API may change before the stable release.
> > Contact [Primer support](https://primer.io/docs/support) before using in production.

> [tab] iOS
>
> > [!NOTE]
> >
> > CocoaPods Trunk stops accepting new versions on 2 December 2026. We recommend Swift Package Manager. If your app uses CocoaPods, follow [Migrate from CocoaPods to Swift Package Manager](https://primer.io/docs/sdk/ios-checkout/v3.0.0-beta/migrate-from-cocoapods.md).
>
> Install the Primer SDK using your preferred package manager:
>
> > [tab] Swift Package Manager
> >
> > 1. In Xcode, go to **File > Add Package Dependencies**
> > 2. Enter the repository URL:
> >
> > ```
> > https://github.com/primer-io/primer-sdk-ios.git
> > ```
> >
> > 3. Under **Dependency Rule**, choose **Exact Version** and enter the beta tag `3.0.0-beta.9`
> > 4. Add `PrimerSDK` to your target
>
> > [tab] CocoaPods (deprecated)
> >
> > CocoaPods is deprecated for native iOS apps. You can use it with the Primer spec repo for a limited time.
> >
> > Add the following to your `Podfile`. Keep both `source` lines at the top, in this order:
> >
> > ```ruby theme={"dark"}
> > source 'https://github.com/primer-io/primer-sdk-ios-specs.git'
> > source 'https://cdn.cocoapods.org/'
> >
> > pod 'PrimerSDK', '3.0.0-beta.9'
> > ```
> >
> > Then run:
> >
> > ```bash theme={"dark"}
> > pod install
> > ```
>
> Your app must target **iOS 15.0** or later.
>
> > [!WARNING]
> >
> > **This is a beta SDK.** The API may change before the stable release.
> > Contact [Primer support](https://primer.io/docs/support) before using in production.

> [tab] React Native
>
> Install the Primer React Native SDK using your preferred package manager. Pin the exact beta version:
>
> > [tab] npm
> >
> > ```bash theme={"dark"}
> > npm install --save-exact @primer-io/react-native@3.0.0-beta.1
> > ```
>
> > [tab] yarn
> >
> > ```bash theme={"dark"}
> > yarn add --exact @primer-io/react-native@3.0.0-beta.1
> > ```
>
> Then install the iOS pods from your app's `ios` folder:
>
> ```bash theme={"dark"}
> cd ios && pod install
> ```
>
> The package brings the native iOS and Android SDKs with it. Don't add `PrimerSDK` to your `Podfile` or `io.primer:android` to your `build.gradle`.
>
> Your app must target **iOS 15.0** or later and Android API level **24** or later. Rebuild the app on both platforms after you install the package: reloading the JavaScript bundle doesn't add native code.
>
> > [!WARNING]
> >
> > **This is a beta SDK.** The API may change before the stable release.
> > Contact [Primer support](https://primer.io/docs/support) before using in production.

## Load and initialize

> [tab] Web
>
> Import and initialize Primer in your application:
>
> ```javascript theme={"dark"}
> import { loadPrimer } from '@primer-io/primer-js';
> loadPrimer();
> ```

> [tab] Android
>
> The SDK initializes automatically when you create a checkout controller. Use `rememberPrimerCheckoutController` in your Composable:
>
> ```kotlin theme={"dark"}
> val checkout = rememberPrimerCheckoutController(
>     clientToken = clientToken,
> )
> ```
>
> The SDK starts loading configuration immediately upon creation.

> [tab] iOS
>
> The SDK initializes automatically when you create a `PrimerCheckout` view. Import PrimerSDK and add it to your SwiftUI view:
>
> ```swift theme={"dark"}
> import SwiftUI
> import PrimerSDK
>
> struct CheckoutView: View {
>   let clientToken: String
>
>   var body: some View {
>     PrimerCheckout(clientToken: clientToken)
>   }
> }
> ```
>
> The SDK starts loading configuration immediately when the view appears.

> [tab] React Native
>
> The SDK initializes automatically when `PrimerCheckoutProvider` mounts. Wrap your checkout UI in it and pass your `clientToken`:
>
> ```tsx theme={"dark"}
> import type { ReactNode } from 'react';
> import { PrimerCheckoutProvider } from '@primer-io/react-native';
>
> export function Checkout({ clientToken, children }: { clientToken: string; children: ReactNode }) {
>   return <PrimerCheckoutProvider clientToken={clientToken}>{children}</PrimerCheckoutProvider>;
> }
> ```
>
> The SDK starts loading configuration as soon as the provider mounts, and ends the session when it unmounts.

## Add the checkout component

> [tab] Web
>
> Create a basic checkout by adding the `primer-checkout` component to your page:
>
> ```html theme={"dark"}
> <primer-checkout client-token="your-client-token"></primer-checkout>
> ```
>
> | Property | Description |
> | - | - |
> | `client-token` | A token retrieved from the [Client Session endpoint](https://primer.io/docs/checkout/client-session.md). Authenticates the checkout session and contains configuration for available payment methods. |

> [tab] Android
>
> Add the checkout to your Composable:
>
> ```kotlin theme={"dark"}
> @Composable
> fun CheckoutScreen(clientToken: String) {
>     val checkout = rememberPrimerCheckoutController(
>         clientToken = clientToken,
>     )
>     val state by checkout.state.collectAsStateWithLifecycle()
>
>     LaunchedEffect(state) {
>         when (state) {
>             is PrimerCheckoutState.Success -> { /* Navigate to confirmation */ }
>             is PrimerCheckoutState.Failure -> { /* Error is shown in the UI */ }
>             else -> Unit
>         }
>     }
>
>     PrimerCheckoutSheet(checkout = checkout)
> }
> ```

> [tab] iOS
>
> Add the checkout view to your screen with a `clientToken` and an `onCompletion` callback:
>
> ```swift theme={"dark"}
> struct CheckoutView: View {
>   let clientToken: String
>
>   var body: some View {
>     PrimerCheckout(
>       clientToken: clientToken,
>       onCompletion: { state in
>         switch state {
>         case .success(let result):
>           print("Payment succeeded: \(result.paymentId)")
>         case let .failure(error, _):
>           print("Payment failed: \(error.errorId)")
>         case .dismissed:
>           print("Checkout dismissed")
>         default:
>           break
>         }
>       }
>     )
>   }
> }
> ```
>
> | Parameter | Type | Description |
> | - | - | - |
> | `clientToken` | `String` | A token retrieved from the [Client Session endpoint](https://primer.io/docs/checkout/client-session.md). Authenticates the checkout session and contains configuration for available payment methods. |
> | `onCompletion` | `((PrimerCheckoutState) -> Void)?` | Optional, defaults to `nil`. Receives `.failure` once per failed attempt, including a failed initialization. If the SDK error screen is on, the checkout stays open for a retry. Receives `.success` or `.dismissed` exactly once. |

> [tab] React Native
>
> Render `PrimerCheckoutSheet` inside `PrimerCheckoutProvider`, and read the result of each payment from `usePrimerCheckout()`:
>
> ```tsx theme={"dark"}
> import { useEffect, useState } from 'react';
> import { Button } from 'react-native';
> import {
>   PrimerCheckoutProvider,
>   PrimerCheckoutSheet,
>   usePrimerCheckout,
> } from '@primer-io/react-native';
>
> function PaymentResult() {
>   const { paymentOutcome } = usePrimerCheckout();
>
>   useEffect(() => {
>     if (paymentOutcome?.status === 'success') {
>       console.log('Payment succeeded:', paymentOutcome.data.payment?.id);
>     } else if (paymentOutcome?.status === 'error') {
>       console.log('Payment failed:', paymentOutcome.error.errorId);
>     }
>   }, [paymentOutcome]);
>
>   return null;
> }
>
> 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}>
>           <PaymentResult />
>           <PrimerCheckoutSheet
>             visible={visible}
>             onRequestDismiss={() => setVisible(false)}
>             onDismiss={() => setClientToken(null)}
>           />
>         </PrimerCheckoutProvider>
>       )}
>     </>
>   );
> }
> ```
>
> | Prop or field | Type | Description |
> | - | - | - |
> | `clientToken` | `string` | Prop of `PrimerCheckoutProvider`. A token retrieved from the [Client Session endpoint](https://primer.io/docs/checkout/client-session.md). Authenticates the checkout session and contains configuration for available payment methods. |
> | `visible` | `boolean` | Prop of `PrimerCheckoutSheet`. The sheet opens when it is `true` and closes when it is `false`. |
> | `onRequestDismiss` | `() => void` | Prop of `PrimerCheckoutSheet`. Called when the shopper asks to close the sheet, and 3 seconds after the success screen appears. The sheet closes only when you set `visible` to `false` here. |
> | `paymentOutcome` | `PaymentOutcome \| null` | From `usePrimerCheckout()`. The result of the latest payment attempt: `'success'`, `'pending'` or `'error'`. By default, the sheet shows its error screen after a failed attempt so the shopper can try again. |
>
> Use a new client token and a new `PrimerCheckoutProvider` for each checkout attempt. Unmount the provider in `onDismiss`, which `PrimerCheckoutSheet` calls after it has closed, as in the example above. See [Installation](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/installation.md#basic-usage).
>
> See [Handle the payment result](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/guides/handle-payment-result.md) for the `onCheckoutComplete` and `onError` callbacks.

## Verify installation

> [tab] Web
>
> Check that components are registered correctly in your browser console:
>
> ```javascript theme={"dark"}
> console.log(customElements.get('primer-checkout'));
> ```

> [tab] Android
>
> Build your project to confirm the SDK is resolved correctly:
>
> ```bash theme={"dark"}
> ./gradlew assembleDebug
> ```
>
> The SDK includes its own ProGuard rules — no additional configuration is needed for release builds.

> [tab] iOS
>
> Build and run your app. If the SDK is installed correctly, you should see the checkout UI with payment methods configured in your Primer Dashboard.
>
> > [!WARNING]
> >
> > If the checkout shows an error screen instead of payment methods, or `onCompletion` receives `.failure`, verify that:
> >
> > * Your `clientToken` is valid and not expired
> > * Payment methods are configured in your [Primer Dashboard](https://dashboard.primer.io)
> >
> > If you turn off the SDK error screen with `PrimerSettings(uiOptions: PrimerUIOptions(isErrorScreenEnabled: false))`, the checkout shows nothing when it fails. The `.failure` in `onCompletion` is then your only signal.

> [tab] React Native
>
> Build and run your app on both platforms:
>
> ```bash theme={"dark"}
> npx react-native run-ios
> npx react-native run-android
> ```
>
> If the SDK is installed correctly, the sheet opens on a loading screen and then shows the payment methods configured in your Primer Dashboard.
>
> > [!WARNING]
> >
> > If the sheet shows an error screen instead of payment methods, verify that:
> >
> > * Your `clientToken` is valid and not expired
> > * Payment methods are configured in your [Primer Dashboard](https://dashboard.primer.io)
> >
> > Read `usePrimerCheckout().error` to find out why the checkout failed to start, then start again with a new client token.

## Framework-specific setup

> [tab] Web
>
> | Framework | Additional Steps |
> | - | - |
> | React 18/19 | See [React Integration Guide](https://primer.io/docs/checkout/primer-checkout/frameworks/react-integration-guide.md) for stable reference patterns |
> | Next.js | See [SSR Guide](https://primer.io/docs/checkout/primer-checkout/frameworks/ssr-guide.md) for client-side loading |
> | Nuxt.js | See [SSR Guide](https://primer.io/docs/checkout/primer-checkout/frameworks/ssr-guide.md) for `onMounted` pattern |
> | SvelteKit | See [SSR Guide](https://primer.io/docs/checkout/primer-checkout/frameworks/ssr-guide.md) for `onMount` pattern |
> | Vue.js (client-only) | No additional setup needed |
> | Vanilla JS | No additional setup needed |
>
> > [!WARNING]
> >
> > **Server-Side Rendering**
> >
> > If you're using Next.js, Nuxt, SvelteKit, or any SSR framework, you must load Primer only on the client side. The Web Components API doesn't exist in Node.js.
> >
> > ```javascript theme={"dark"}
> > useEffect(() => {
> >   if (typeof window !== 'undefined') {
> >     loadPrimer();
> >   }
> > }, []);
> > ```
> >
> > See the [SSR Guide](https://primer.io/docs/checkout/primer-checkout/frameworks/ssr-guide.md) for complete patterns.

> [tab] Android
>
> No framework-specific setup is needed. The SDK integrates directly with Jetpack Compose.

> [tab] iOS
>
> No framework-specific setup is needed. `PrimerCheckout` integrates directly with SwiftUI.
>
> For UIKit apps, use [`PrimerCheckoutPresenter`](https://primer.io/docs/sdk/ios-checkout/v3.0.0-beta/guides/uikit-integration) to present the checkout from a `UIViewController`.

> [tab] React Native
>
> No framework-specific setup is needed. Primer Checkout integrates with React Native through components and hooks.
>
> Some features need setup in your iOS and Android projects: URL schemes, Apple Pay, Google Pay, and the optional native 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).

## See also

> [card] [First Payment](https://primer.io/docs/checkout/primer-checkout/first-payment.md)
>
> Accept your first payment

> [card] [Styling](https://primer.io/docs/checkout/primer-checkout/build-your-ui/styling-customization.md)
>
> Customize the appearance

> [card] [Layout](https://primer.io/docs/checkout/primer-checkout/build-your-ui/layout-customization.md)
>
> Control component arrangement

> [card] [Core Concepts](https://primer.io/docs/checkout/primer-checkout/core-concepts.md)
>
> Understand the architecture


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