isLoading: boolean and error: Error | null (see Introduction); the sections below list each hook’s specific returns.
usePlans
Returns the merchant’s live plans — the flat list fromGET /v1/plans?status=active. Customers only ever see active plans (never draft, archived, or migrated). For a customer-facing pricing page with tiers, intervals, entitlements, credit packages, and addons, use usePricing instead.
Parameters — none.
Returns
plans—Plan[]— the active plans, or[]while loading. Each plan:
Plan identifier.
Display name.
Stable slug.
Optional description.
Whether the plan is publicly listed.
Arbitrary merchant metadata.
useProducts
Returns the org’s active product catalog — read-only, fromGET /v1/products?status=active. Customers only ever see live products; archived ones are tombstones and never surface. This also powers usePricing’s single-product auto-derive fallback: when there’s exactly one active product, a portal with no explicit productId self-resolves to it.
Parameters — none.
Returns
products—Product[]— the active products, or[]while loading. Each product:
Product identifier.
Owning org.
Display name.
Stable slug.
Optional description.
Optional product image.
Always
active from this hook.Arbitrary merchant metadata.
ISO timestamp.
ISO timestamp.
usePricing
Returns the complete customer-facing catalog for one product fromGET /v1/public/pricing/:productId: tiers, plans-per-tier (interval variants), entitlements, credit packages, addons, and a canonical top-level features[] row list for building a pricing matrix. The server filters to self-serve tiers automatically. This is the hook customer-facing pricing pages want — not usePlans, the flat live-plan list.
Parameters
The product to load pricing for. Optional — when omitted, it’s derived in this order:
- Explicit arg —
usePricing('prod_xxx') UnitPayConfig.productId(the escape hatch set on<UnitPayProvider>)- The active subscription’s
productId(the sub is the answer) - A single-product org auto-resolves (
useProducts()length === 1) - Otherwise
null→ returns{ pricing: null, isLoading: false, error: null }(multi-product org with no sub — passproductIdexplicitly)
isLoading stays true.pricing— thePricingResponsematrix, ornullwhen no product could be resolved / while loading:
Catalog display currency.
{ id, name, slug, description, imageUrl }.Canonical matrix row order — the union of every entitlement slug across every plan in every tier, sorted by
displayOrder. Each row carries slug, name, eventName (billable metric, or null), and creditCurrencyId (wallet it debits, or null).The pricing columns. Each tier carries
plans[] (interval variants), addons[], creditPackages[], an entitlementBySlug lookup (branches on mode: unlimited / quota / rate), plus presentation flags (isPopular, isForeverFree, isSelfServe, isSalesLed, ctaLabel, intervals[]).useBranding
Returns the customer-facing merchant identity for the current org — what the portal renders in its header instead of a hardcoded asset. Read-only, fromGET /v1/branding, and cached aggressively since branding changes rarely. It’s managed in the merchant dashboard.
Parameters — none.
Returns
branding— theBrandingobject, ornullwhile loading:
Merchant display name. Always present.
Merchant logo URL, or
null if none uploaded.Merchant website URL, or
null if unset — powers the portal’s “Return to ” back-link.Typed appearance/theme config (accents, CSS overrides), or
null if unset.See also
Checkout
Preview and start a subscription to a plan from the catalog.
Entitlements & gates
What each plan’s entitlements grant the customer at runtime.
Credits & wallets
The credit packages and wallets referenced by the pricing matrix.