UnitPayProvider wraps your application and provides the UnitPay client to every hook and component. It manages the TanStack Query cache and the portal-session token lifecycle (automatic refresh).
Usage
Mint a portal token on your server, then pass it — along with thecustomerId — to the provider:
The
portalToken is a short-lived JWT minted server-side with @unitpay/node
(unitpay.portalSessions.create({ customerId })). The SDK refreshes it automatically — you
do nothing after the initial mint. onSessionExpired fires only when refresh fails for good.Props
config (UnitPayConfig)
Route calls through a same-origin proxy (see the Next.js adapter). Takes precedence over
apiBaseUrl.Pin a product for multi-product orgs. Hooks like
usePricing() prefer this; single-product orgs can omit it (the SDK auto-resolves the only product).