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

# Component Architecture Explorer — React Native

> Explore the React Native Checkout Components hierarchy, hooks and customization points interactively.

Explore the React Native Checkout Components architecture interactively. `PrimerCheckoutProvider` owns the checkout session, and you customize the checkout by choosing which components to render and by reading the session through hooks. Click any component to see its props, the hooks that read it, the theme tokens it draws with, and copyable TypeScript code examples.

Component & Hook Hierarchy

**PrimerCheckoutProvider**

Prebuilt → the whole checkout

**PrimerCheckoutSheet**

Or your own layout → components and hooks

**PrimerPaymentMethodList**

**PrimerAcceptedCardNetworks**

**PrimerCardFormProvider**

**PrimerCardForm**

Card inputs, also usable on their own

**PrimerCardNumberInput**

**PrimerCardNetworkSelector**

**PrimerExpiryDateInput**

**PrimerCVVInput**

**PrimerCardholderNameInput**

**Your Pay button**

Status screens → from usePrimerCheckout() state

**PrimerLoadingScreen**

**PrimerSuccessScreen**

**PrimerErrorScreen**

**PrimerStatusScreenLayout**

Component

card
Card form

field
Card input

yours
Your own component

Component Details

***

## Two ways to integrate

| Goal | Use |
| - | - |
| Fastest integration, default screens | [`PrimerCheckoutSheet`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/primer-checkout-sheet) inside `PrimerCheckoutProvider`: the prebuilt bottom sheet. It runs the whole checkout, including saved payment methods and the billing address. |
| Your own layout | [`PrimerCheckoutProvider`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/primer-checkout-provider) with the components and hooks: [`PrimerCardFormProvider` and `PrimerCardForm`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/primer-card-form) or the [card inputs](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/card-inputs.md), [`PrimerPaymentMethodList`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/payment-methods/primer-payment-method-list), the [status screens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/status-screens.md), and [`usePrimerVaultManager`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/payment-methods/use-primer-vault-manager) for saved payment methods. |

`PrimerCheckoutProvider` shares the session through React context, and the components and hooks below it read it from there.

***

## Props and hooks

Each component takes a few props, and the hooks expose the state behind it, so you can replace any part with views of your own. Replace one component and the others keep their default rendering.

| Component | Customize with props | Build your own with |
| - | - | - |
| `PrimerCheckoutSheet` | `visible`, `onRequestDismiss`, `onDismiss`, `dismissOnBackdropPress` | The components below |
| `PrimerCardForm` | `onSubmit`, `autoFocus`, `editable`, `style`, `testID` | The card inputs and [`usePrimerCardForm`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/use-primer-card-form) |
| Card inputs | `theme`, `label`, `placeholder`, `showLabel`, `editable`, `style`, `inputStyle`, `labelStyle` | `PrimerTextInput` and `usePrimerCardForm` |
| `PrimerCardNetworkSelector` | `testID` | [`usePrimerCardNetworkSelection`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/card-networks#useprimercardnetworkselection) |
| `PrimerAcceptedCardNetworks` | `networks`, `style`, `testID` | `usePrimerCheckout().acceptedCardNetworks` |
| `PrimerPaymentMethodList` | `onSelect`, `include`, `exclude`, `data`, `onLoad`, `style` | `usePrimerPaymentMethods` and [`usePrimerPaymentMethod`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/payment-methods/use-primer-payment-method) |
| Status screens | `title`, `subtitle`, `icon`, plus `onDismiss` and `autoDismissMs` on the success screen and `onRetry` and `onChooseOtherMethod` on the error screen | `PrimerStatusScreenLayout` and [`usePrimerCheckout`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/use-primer-checkout) |

`PrimerCardNumberInput` already shows `PrimerCardNetworkSelector` on a co-badged card. Render the selector yourself only next to your own card number field, or two selectors appear.

Visual styling comes from the `theme` prop of `PrimerCheckoutProvider`, a [`PrimerThemeOverride`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/primer-theme-override) with `light` and `dark`, each taking `colors`, `spacing`, `typography`, `radii`, `sizes` and `widths`. Setting `colors.brand` also moves `focus`, `loader` and `borderOutlinedSelected`, and through `focus` the `borderOutlinedFocus` and `borderTransparentFocus` colors, unless you set them yourself. See [Tokens that follow others](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/color-tokens.md#tokens-that-follow-others). A `PrimerTextInputTheme` on one input restyles only that input, and `usePrimerTheme()` gives you the same tokens for your own views.

***

## Hooks and state

Your components read the checkout session through hooks. Call each hook below the provider it needs. Outside it, the hook throws an error that names the missing provider.

| Hook | Works inside | Gives you |
| - | - | - |
| [`usePrimerCheckout`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/use-primer-checkout) | `PrimerCheckoutProvider` | `isReady`, `error`, `clientSession`, `acceptedCardNetworks`, `paymentOutcome` and the checkout actions |
| [`usePrimerPaymentMethod`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/payment-methods/use-primer-payment-method) | `PrimerCheckoutProvider` | `kind`, `isAvailable` and `start()` for one payment method, with the state and actions of its kind |
| [`usePrimerPaymentMethods`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/payment-methods/primer-payment-method-list#useprimerpaymentmethods) | `PrimerCheckoutProvider` | `paymentMethods` and `isLoading`, ready to render |
| [`usePrimerVaultManager`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/payment-methods/use-primer-vault-manager) | `PrimerCheckoutProvider` | Saved payment methods, `pay()` and `deleteVaultedPaymentMethod()` |
| [`usePrimerCardNetwork`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/card-networks#useprimercardnetwork) | `PrimerCheckoutProvider` | `network`, `descriptor` and `iconSource` of the detected network |
| [`usePrimerCardNetworkSelection`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/card-networks#useprimercardnetworkselection) | `PrimerCheckoutProvider` | `availableNetworks`, `selectedNetwork` and `selectNetwork()` for co-badged cards |
| [`usePrimerCardForm`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/use-primer-card-form) | `PrimerCardFormProvider`, inside `PrimerCheckoutProvider` | Field values, update functions, `isValid`, `errors` and `submit()` |
| [`usePrimerTheme`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/primer-theme-override#useprimertheme) | Anywhere | The tokens in effect. Outside the provider, the default tokens for the device color scheme |
| [`usePrimerLocalization`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/use-primer-localization) | Anywhere | Translated strings, and currency and date formatting |

### Checkout state

Derive the checkout state from `usePrimerCheckout()`:

| Condition | Meaning |
| - | - |
| `isReady` is `false` and `error` is `null` | The checkout is starting. |
| `error` is not `null` | The checkout failed to start. |
| `isReady` is `true` | The checkout started and the payment methods are loaded. |
| `paymentOutcome` is not `null` | The latest payment attempt has a result. |

### PaymentOutcome

`paymentOutcome` is the result of the latest payment attempt, shared by all payment methods. Use it as your main result signal.

| `status` | Fields | Description |
| - | - | - |
| `'success'` | `data: CheckoutData` | The payment was created and its status isn't `FAILED`. |
| `'pending'` | `data: CheckoutData` | A Stripe ACH payment that awaits settlement. |
| `'error'` | `error: PrimerError`, `data: CheckoutData \| null` | The payment attempt failed. The shopper can try again, and the next attempt sets a new outcome. |

### usePrimerCardForm

| Field | Type | Description |
| - | - | - |
| `cardNumber`, `expiryDate`, `cvv`, `cardholderName` | `string` | The field values. |
| `isValid` | `boolean` | `true` when the native SDK reports the card data as valid. Gate your Pay button on it. |
| `errors` | `CardFormErrors` | The error message of each card field that should show one now. |
| `isSubmitting` | `boolean` | `true` while `submit()` hands the card to the native SDK. |
| `descriptor` | object | Traits of the detected network, including `cvvLength` and `cvvLabel`. |
| `isCardholderNameVisible` | `boolean` | `false` when the client session turns off the cardholder name. |
| `binData` | `BinData \| null` | The BIN data the native SDK reports for the card number. |
| `submit` | `() => Promise<void>` | Submits the card. It never rejects: read the result from `paymentOutcome`. |

***

## Composing custom UI

Wrap your layout in `PrimerCheckoutProvider` and `PrimerCardFormProvider`, start the card payment method, place `PrimerCardForm` or the card inputs, and add your own Pay button. The components read the session from the providers above them.

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

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

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

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

  if (!card.isAvailable) return null;

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

The payment result arrives in `usePrimerCheckout().paymentOutcome`. To offer the other payment methods, render `PrimerPaymentMethodList` next to the card form and start the chosen method with `usePrimerPaymentMethod(type)`.

> [!WARNING]
>
> Without `PrimerCardFormProvider` above them, `usePrimerCardForm`, `PrimerCardForm` and the card inputs throw. Without a call to `start()` on `usePrimerPaymentMethod('PAYMENT_CARD')`, the card form validates nothing and `submit()` doesn't pay.

***

## Related

* [API overview](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/overview.md) — Full React Native Checkout API reference
* [PrimerCheckoutProvider](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/primer-checkout-provider.md) — The root component, its theme and its callbacks
* [PrimerCardForm](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/primer-card-form.md) — The card form and `PrimerCardFormProvider`
* [Design Tokens Explorer](https://primer.io/docs/checkout/primer-checkout/build-your-ui/design-tokens-explorer-react-native.md) — Explore theme tokens
* [Card Form Layout Builder](https://primer.io/docs/checkout/primer-checkout/build-your-ui/card-form-layout-builder.md) — Build card form layouts


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