Use this file to discover all available pages before exploring further.
The @lavapayments/checkout package provides a React hook for embedding Lava’s checkout flow as a full-screen iframe overlay. It handles the complete payment flow — phone verification, payment setup, and subscription creation.
The SDK exports a single hook: useLavaCheckout. It returns an open function that launches the checkout iframe.
const { open } = useLavaCheckout({ onSuccess: ({ checkoutSessionId, customerId }) => { // Checkout completed — customerId is the billing relationship ID. // Store it in your database linked to your user. }, onCancel: ({ checkoutSessionId }) => { // User closed the checkout overlay without completing. }, onError: ({ checkoutSessionId, error }) => { // Session token is invalid or malformed. },});// Pass the checkout_session_token created by your backend (see below).open(checkoutSessionToken);
All callbacks are optional.
onSuccess is the easiest way to capture the customerId, but the user can close their browser before it fires. For reliable server-side capture, use the customer.created webhook. In production, use both: the callback for instant UI feedback, the webhook for backend persistence.