Documentation Index
Fetch the complete documentation index at: https://yanhgming.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
@marlin/sdk/react gives you three exports — MarlinProvider, MarlinCheckoutButton, and useMarlinCheckout — that let you open a hosted checkout overlay from React without writing any iframe or postMessage code yourself. The provider holds your publishable key in context; the button and hook consume it to launch and manage the checkout.
Installation
@marlin/sdk/react is included in the main @marlin/sdk package. Import from the /react subpath:
MarlinProvider
Wrap your application (or the subtree that contains checkout UI) with MarlinProvider. It accepts your publishable key and an optional checkout base URL override.
Your Marlin publishable key. This key is safe to include in client-side code — it is distinct from your secret API key.
Override the checkout base URL. Use this to point at a staging environment during development.
The React subtree that can use
useMarlinCheckout and MarlinCheckoutButton.MarlinCheckoutButton
MarlinCheckoutButton renders a <button> that opens the checkout overlay when clicked. Pass the invoice ID and optional callbacks directly as props.
"Pay with Marlin". Override it with the label prop.
Props:
The invoice ID to pay. The checkout overlay loads the invoice’s payment page.
Called when the user completes payment. Receives a
CheckoutResult with invoiceId, transactionSignature, and status: "paid".Called when the user closes the checkout overlay without paying.
Called when an error occurs during the checkout flow.
Visual theme for the checkout overlay. Defaults to
"auto", which follows the user’s system preference.Text label rendered inside the button.
<button> HTML attributes (except onClick and onError) are forwarded to the underlying element, so you can add className, disabled, data-* attributes, and so on.
useMarlinCheckout
Use the useMarlinCheckout hook when you need to trigger checkout from custom UI — a link, a card click, or a form submission — rather than a dedicated button.
The hook returns { open, isOpen, close }.
| Name | Type | Description |
|---|---|---|
open | (opts: CheckoutOptions) => void | Opens the checkout overlay. Accepts the same options as MarlinCheckoutButton. |
isOpen | boolean | true while the checkout overlay is visible. |
close | () => void | Programmatically closes the overlay. |
useMarlinCheckout must be called inside a component that is a descendant of MarlinProvider. Calling it outside throws: "useMarlinCheckout must be used within a <MarlinProvider>.".