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

# API Reference

> Complete API reference for the Primer Checkout React Native SDK.

> [!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.

Primer Checkout for React Native is a set of React components and hooks. You wrap your checkout in [`PrimerCheckoutProvider`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/primer-checkout-provider), then render the prebuilt [`PrimerCheckoutSheet`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/primer-checkout-sheet) or build your own layout from the components and hooks below. Import everything from `@primer-io/react-native`.

## Core API

| API | Description |
| - | - |
| [`PrimerCheckoutProvider`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/primer-checkout-provider) | Root component. Starts the checkout session from a client token and provides the session, theme and callbacks to everything below it. |
| [`usePrimerCheckout`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/use-primer-checkout) | Hook that returns the checkout state, the payment outcome and the checkout actions. |
| [`PrimerCheckoutSheet`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/primer-checkout-sheet) | Prebuilt bottom sheet that runs the whole checkout: payment method selection, payment forms and result screens. |

## Card form

| API | Description |
| - | - |
| [`PrimerCardForm`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/primer-card-form) | Card form with the card number, expiry date, CVV and cardholder name fields, and `PrimerCardFormProvider`, which holds the card form state. |
| [`usePrimerCardForm`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/use-primer-card-form) | Hook for the card field values, validation and submit. |
| [Card inputs](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/card-inputs.md) | Individual fields: `PrimerCardNumberInput`, `PrimerExpiryDateInput`, `PrimerCVVInput`, `PrimerCardholderNameInput`, and the base `PrimerTextInput`. |
| [Card networks](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/card-networks.md) | Network detection and co-badged card selection: `usePrimerCardNetwork`, `usePrimerCardNetworkSelection`, `PrimerCardNetworkSelector` and `PrimerAcceptedCardNetworks`. |
| [Billing address](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/billing-address.md) | How `PrimerCheckoutSheet` collects the billing address. |

## Payment methods

| API | Description |
| - | - |
| [`PrimerPaymentMethodList`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/payment-methods/primer-payment-method-list) | List of payment method buttons, and the `usePrimerPaymentMethods` hook behind it. |
| [`usePrimerPaymentMethod`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/payment-methods/use-primer-payment-method) | One hook for any payment method. It returns the state and actions for the method's kind, such as card, native UI, bank selection, Klarna or Stripe ACH. |
| [`usePrimerVaultManager`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/payment-methods/use-primer-vault-manager) | Saved payment methods: list, select, pay and delete. |

## Theming

| API | Description |
| - | - |
| [`PrimerThemeOverride`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/primer-theme-override) | The provider's `theme` prop with `light` and `dark` token overrides, and the `usePrimerTheme` hook. |
| [Color tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/color-tokens.md) | `PrimerColorTokens`: colors for each appearance mode. |
| [Spacing tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/spacing-tokens.md) | `PrimerSpacingTokens`: padding and gaps. |
| [Typography tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/typography-tokens.md) | `PrimerTypographyTokens`: font family and text styles. |
| [Shape tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/shape-tokens.md) | `PrimerRadiusTokens`, `PrimerSizeTokens` and `PrimerWidthTokens`: corner radii, sizes and border widths. |

## Common objects

| API | Description |
| - | - |
| [`PrimerSettings`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/primer-settings) | SDK configuration you pass to the provider. |
| [`PrimerError`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/primer-error) | Error fields, and where errors arrive. |
| [Status screens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/status-screens.md) | `PrimerLoadingScreen`, `PrimerSuccessScreen`, `PrimerErrorScreen` and `PrimerStatusScreenLayout`. |
| [`usePrimerLocalization`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/use-primer-localization) | Translated strings, and currency and date formatting in the device language. |
| [Checkout data](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/checkout-data.md) | `CheckoutData`, `CheckoutDataPayment`, `PaymentOutcome` and `ClientSession`. |

## Provider and hooks pattern

Every integration has one `PrimerCheckoutProvider`. The components and hooks below it share its checkout session. You customize the checkout by choosing which components to render and by building your own UI with the hooks.

The quickest integration renders the prebuilt sheet inside the provider:

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

function Checkout({ clientToken, visible, onClose }: {
  clientToken: string;
  visible: boolean;
  onClose: () => void;
}) {
  return (
    <PrimerCheckoutProvider clientToken={clientToken}>
      <PrimerCheckoutSheet visible={visible} onRequestDismiss={onClose} />
    </PrimerCheckoutProvider>
  );
}
```

For your own layout, compose the components and hooks inside the provider. A card payment needs `PrimerCardFormProvider` around the card form, and the card payment method started with `usePrimerPaymentMethod('PAYMENT_CARD')`:

```tsx theme={"dark"}
import { useEffect } from 'react';
import { Button } from 'react-native';
import {
  PrimerCardForm,
  PrimerCardFormProvider,
  PrimerCheckoutProvider,
  usePrimerCardForm,
  usePrimerPaymentMethod,
} from '@primer-io/react-native';

function CardPayment() {
  const card = usePrimerPaymentMethod('PAYMENT_CARD');
  const cardForm = usePrimerCardForm();
  const startCard = card.kind === 'card' && card.isAvailable ? card.start : undefined;

  useEffect(() => {
    startCard?.();
  }, [startCard]);

  return (
    <>
      <PrimerCardForm onSubmit={cardForm.submit} />
      <Button title="Pay" disabled={!cardForm.isValid} onPress={() => cardForm.submit()} />
    </>
  );
}

export function Checkout({ clientToken }: { clientToken: string }) {
  return (
    <PrimerCheckoutProvider clientToken={clientToken}>
      <PrimerCardFormProvider>
        <CardPayment />
      </PrimerCardFormProvider>
    </PrimerCheckoutProvider>
  );
}
```

Set your own paying flag when the shopper taps Pay and clear it only if the payment fails, so a second tap can't start a second payment. See [Disable buttons during payment](https://primer.io/docs/checkout/primer-checkout/guides-and-recipes/disable-buttons-during-payment.md).

Read the result of every payment from [`usePrimerCheckout().paymentOutcome`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/use-primer-checkout). See [Handle the payment result](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/guides/handle-payment-result.md).

### Where each hook works

| Hook | Works inside |
| - | - |
| `usePrimerCheckout`, `usePrimerPaymentMethods`, `usePrimerPaymentMethod`, `usePrimerVaultManager`, `usePrimerCardNetwork`, `usePrimerCardNetworkSelection` | `PrimerCheckoutProvider` |
| `usePrimerCardForm` | `PrimerCardFormProvider`, inside `PrimerCheckoutProvider` |
| `usePrimerTheme` | Anywhere. Outside the provider it returns the default tokens for the device color scheme. |
| `usePrimerLocalization` | Anywhere |

A hook called outside the provider it needs throws an error that names the missing provider.

## See also

> [card] [PrimerCheckoutProvider](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/primer-checkout-provider.md)
>
> Start a checkout session and wrap your checkout UI.

> [card] [PrimerCheckoutSheet](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/primer-checkout-sheet.md)
>
> Run the whole checkout in a prebuilt bottom sheet.

> [card] [usePrimerCheckout](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/use-primer-checkout.md)
>
> Read the checkout state and the payment outcome.

> [card] [Handle the payment result](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/guides/handle-payment-result.md)
>
> React to successful, pending and failed payments.


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