@withlocus/checkout-react. Create sessions on your server, then render checkout on the client.
Install
@withlocus/checkout-react on the client to render checkout. Requires React 17+.
Quick start (without receipt)
Step 1: Create a session
There is no separate server-side npm package for checkout session creation. CallPOST https://api.paywithlocus.com/api/checkout/sessions from your server with your Locus API key.
Step 2: Render checkout
Pass the session ID to theLocusCheckout component on the client.
Full example (Next.js)
A complete Next.js flow — API route creates the session, page renders the checkout.With receipt
PassreceiptConfig in the request body when you create the session to attach line items, tax, and company info. The client-side LocusCheckout component stays exactly the same. It automatically renders receipt details when the session has them.
Create a session with receipt
Render checkout
The
LocusCheckout component is identical whether the session uses receipts or not. All receipt configuration happens in your POST /checkout/sessions request.receiptConfig fields
After payment, receipt details also appear in the buyer’s Purchases tab on the Locus dashboard.
Display modes
Themode prop controls how the checkout UI appears.
Embedded
Renders inline in your page. Best for dedicated checkout pages.Popup
Opens checkout in a centered popup window. CallsonCancel if the popup is closed.
Redirect
Navigates the browser to the hosted checkout page. Renders nothing.Using the hook
For custom checkout buttons or non-standard flows, useuseLocusCheckout instead of the LocusCheckout component.
openPopup, redirectToCheckout, and getCheckoutUrl — see the full API in the Merchant Integration reference.