Skip to main content

Recommended: JavaScript SDK with React Hooks

For new React apps, we recommend the JavaScript SDK with React Hooks (@dynamic-labs-sdk/react-hooks) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the React quickstart (JavaScript SDK) to get started.

Overview

The MoonPay integration lets users buy crypto with fiat currency directly from your app. Once enabled, Dynamic shows a token selector screen inside the widget where the user picks a token, reviews the destination wallet, and is forwarded to MoonPay’s hosted checkout in a new tab. For a headless integration that bypasses the widget entirely, use the exported MoonPayOnramp component with an onPaymentCreated callback.

Dashboard Setup

  1. Go to the Funding tab in your Dynamic developer dashboard.
  2. Under “Fiat on-ramps”, toggle on MoonPay and accept any additional terms.
  3. Save the settings.
Before continuing, make sure you’re using the latest version of the Dynamic SDK packages.

Widget Implementation

Once enabled, users will see MoonPay listed in the widget’s deposit screen. Selecting it opens the built-in MoonPay screen where they:
  1. Choose a token supported by MoonPay for their connected wallet’s chain.
  2. Review the destination wallet address.
  3. Click Continue to MoonPay — Dynamic opens the signed MoonPay widget in a new tab.
No additional configuration is required for the default widget flow.

Programmatic Implementation

Using the useOnramp Hook

Use useOnramp to trigger the MoonPay flow from your own UI. Calling open with OnrampProviders.MoonPay navigates the Dynamic widget to the MoonPay token selector screen.
You can also pass address and token to pre-fill the widget:

Using the MoonPayOnramp Component

For a fully custom integration that bypasses the Dynamic widget, import MoonPayOnramp directly from @dynamic-labs/sdk-react-core. This renders a standalone token selector and wallet card that generates a signed MoonPay URL. Supply an onPaymentCreated callback to intercept the URL and handle it yourself instead of opening a popup:
Without onPaymentCreated, the component opens MoonPay in a new tab automatically when the user confirms.

MoonPayOnramp Props

Headless: Resolving the URL Only

If you only need the signed URL (e.g. to embed it in your own iframe), use getMoonPayUrl from @dynamic-labs-sdk/client:
See the getMoonPayUrl and getMoonPayCurrencies reference docs for the full parameter list.

Customizing the Onramp Provider List

To customise how MoonPay appears alongside other providers, use the onrampOptions override in DynamicContextProvider:
See Customizing the Onramp Experience for the full OnrampOption structure and more examples.

Supported Tokens

Supported tokens vary by chain and network. Fetch them at runtime with getMoonPayCurrencies:
See the getMoonPayCurrencies reference for more details.

Error Handling

The MoonPayOnramp component surfaces errors inline. When using the hook or the headless API, handle these errors explicitly:
Last modified on June 25, 2026