Skip to main content

Plans

Your public pricing, the same data as the server’s billing.plans(). For a complete pricing page, use <PricingTable>.

Checkout

Pass a price id or slug, not a plan id. openCheckout() redirects the browser; createCheckout() returns the URL instead. Both take the buyer’s prepaid choices as a second argument, [{ feature_key, steps }]. Checkout redirects to the payment provider’s page. For an embedded card form, use the server’s embedded card checkout.
A checkout for someone who’s already subscribed creates a second subscription. To let subscribers switch plans, use usePlanSwitch().

Subscription

isActive is true for ACTIVE and TRIALING. Pass a product slug to useSubscription() if your project has several products.

Change plan and cancel

A plan change applies immediately. To skip proration, pass { prorationBehavior: 'none' } as a third argument. Call refetch() after either one: useSubscription() doesn’t update on its own.

Plan picker

usePlanSwitch() starts a checkout for someone without a subscription and changes the plan of someone who has one, so a subscriber never ends up with two. <PricingTable> uses it.
Without a subscription, selectPlan() goes straight to checkout. With one, it sets pending and waits for confirmSwitch(). It also returns switchError, checkoutError and checkoutPriceId, the price being redirected to.

Billing portal

The payment provider’s page, where the user updates their payment method, downloads invoices and manages their plan. openPortal() redirects; createPortal() returns the URL.