Skip to main content
The useCheckout hook creates checkout sessions using your backend checkout route. By default it calls POST /api/priceos/v1/checkout.
Setup first: see the React integration guide.

Usage

Parameters

string
Optional fallback customerId used when openCheckout/createCheckoutSession are called without customerId in the body.

Returns

(body) => Promise<CreateCustomerCheckoutResponse>
Creates a checkout session and returns { url }.
(body) => Promise<CreateCustomerCheckoutResponse>
Creates a checkout session, then redirects the browser to Stripe Checkout.

Body fields

string
required
Product key from your PriceOS dashboard to start checkout for.
string
Optional Stripe price ID override. When omitted, PriceOS uses the product’s default active Stripe price.
string
Optional URL to redirect to when checkout succeeds.
string
Optional URL to redirect to when checkout is canceled.
string
Optional customer override. If omitted, the hook uses options.customerId or your backend identifyCustomer.
Record<string, string>
Optional metadata to attach to the Stripe checkout session.
Record<string, unknown>
Optional Stripe Checkout session params to merge into the request.

Example