Skip to main content

Overview

The @yuno-payments/react package provides pre-built React components and hooks for integrating Yuno checkout into your React application. Components handle SDK lifecycle management, PCI compliance, and payment state automatically.
React components wrap the Yuno Web SDK. All features available in the Web SDK are accessible through React components and hooks.

Prerequisites

Installation

YunoProvider

Wrap your application (or the section that uses Yuno components) with <YunoProvider> to initialize the SDK context:

YunoProvider Props

Do not render multiple <YunoProvider> instances in the same React tree. Use a single provider at the top level.

YunoCheckout Component

Renders the full checkout UI with all available payment methods.

YunoCheckout Props

Always verify the final payment status server-side via webhooks or the GET payment API. Client-side callbacks should not be the sole source of truth.

YunoPaymentForm Component

Renders a card-only payment form for custom checkout flows where you control payment method selection.

YunoPaymentForm Props

Hooks

useYunoPayment

Provides imperative control over the payment flow. Use this hook when you need to trigger submission programmatically.

useYunoPayment Return Type

useYunoCheckoutSession

Creates and manages checkout sessions client-side. Useful when session creation needs to be triggered dynamically.

useYunoCheckoutSession Return Type

TypeScript Interfaces

Theming with CSS Variables

In addition to the theme prop on <YunoProvider>, you can override styles using CSS variables:
CSS variables take the lowest precedence. The theme prop on <YunoProvider> overrides CSS variables, and the Checkout Builder in the Dashboard is overridden by both.

Error Boundary Integration

Wrap Yuno components in a React error boundary to handle unexpected SDK errors gracefully:

Server-Side Rendering (Next.js)

Yuno components require browser APIs and cannot render on the server. Use dynamic imports with SSR disabled:
Always create checkout sessions server-side (e.g., in getServerSideProps or a Route Handler) to keep your private API key secure.

Complete Example

A full checkout page combining provider, session management, and payment handling:

Testing with React Testing Library

Since Yuno SDK components depend on browser APIs and external scripts, mock the components in unit tests and use end-to-end tests (e.g., Cypress, Playwright) for full integration testing against the sandbox environment.