Skip to main content
Use react-native-webview to embed frames in React Native applications. The WebView communicates with your app through the ReactNativeWebView JavaScript interface.
Read the manual integration overview for core concepts before you continue.

Setup

The react-native-webview library automatically injects the ReactNativeWebView JavaScript interface into the WebView. The frame detects this interface and uses it for communication between the frame and your app. You don’t need to inject a custom JavaScript bridge.

Dependencies

Install react-native-webview to render frames in your app.
If targeting iOS, you may also need to run:
The connect and check frames require X25519 key exchange to encrypt client credentials. The examples below use noble-curves, but you can use any library that supports X25519 and AES-GCM. You also need a polyfill for getRandomValues (MDN) which is only available in browsers.

Base WebView component

Create a reusable base component for frame communication:
MoonPayWebView.tsx

Encryption utility

When using the connect or check frame, you generate an X25519 keypair and provide the public key to the frame. The frame encrypts the returned client credentials with this key.

Key generation

Generate an X25519 keypair for secure communication:
crypto.ts

Decryption utility

Decrypt the encrypted credentials returned from connect/check frames:
decrypt.ts

Check frame

The check frame verifies whether a customer already has an active connection. It’s headless — no UI is rendered. See check frame reference for event details.

Check component

Usage


Connect frame

The connect frame establishes a customer connection to your application. See connect frame reference for event details.

Connect component

Usage


Apple Pay frame

The Apple Pay frame renders the Apple Pay button and handles the payment flow. See Apple Pay frame reference for event details.

Apple Pay component

Usage


Google Pay frame

The Google Pay frame renders the Google Pay button and handles the payment flow. See Google Pay frame reference for event details.

Google Pay component

Usage


Add Card frame

The add card frame lets a customer save a new card to their account. See add card frame reference for event details.

What you’ll need

Before you initialize the add card frame, you need:
  1. A clientToken from a successful connect flow

Add Card component

Usage


Buy frame

The buy frame processes a card payment for a quote. It is headless — rendered at zero size — while the customer completes payment. If 3-D Secure is required, the frame emits a challenge event with a URL you open in a separate challenge frame. See buy frame reference for event details.

What you’ll need

Before you initialize the buy frame, you need:
  1. A clientToken from a successful connect flow
  2. A valid quote signature for the transaction

Buy component

Challenge component

Usage


Widget frame

For payment methods beyond Apple Pay — including credit/debit cards, Google Pay, bank transfers, and more — use the widget frame. It renders the full MoonPay buy experience inside a WebView, including payment-method selection and transaction confirmation. See pay with widget for a full walkthrough.

Widget component

Usage