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

Usage

const { createCustomerPortalSession, openCustomerPortal } = useCustomerPortal(options?)

Parameters

options.customerId
string
Optional fallback customerId used when openCustomerPortal/createCustomerPortalSession are called without customerId.

Returns

createCustomerPortalSession
(body?) => Promise<CreateCustomerPortalResponse>
Creates a portal session and returns { url }.
openCustomerPortal
(body?) => Promise<CreateCustomerPortalResponse>
Creates a portal session, then redirects the browser to Stripe Customer Portal.

Body fields

customerId
string
Optional customer override. If omitted, the hook uses options.customerId or your backend identifyCustomer.

Example

import { useCustomerPortal } from "priceos/react";

export function ManageBillingButton() {
  const { openCustomerPortal } = useCustomerPortal();

  async function onClick() {
    await openCustomerPortal();
  }

  return <button onClick={onClick}>Manage billing</button>;
}