Skip to main content
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.

Two ways to integrate

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

Checkout state

Derive the checkout state from usePrimerCheckout():

PaymentOutcome

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

usePrimerCardForm


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