> ## Documentation Index
> Fetch the complete documentation index at: https://docs.priceos.com/llms.txt
> Use this file to discover all available pages before exploring further.

# useCustomerPortal

> Create and open Stripe customer portal sessions from React.

The `useCustomerPortal` hook creates Stripe customer portal sessions using your backend route.
By default it calls `POST /api/priceos/v1/customer-portal`.

<Tip>
  Setup first: see the [React integration guide](/react-integration).
</Tip>

## Usage

```tsx theme={null}
const { createCustomerPortalSession, openCustomerPortal } = useCustomerPortal(options?)
```

## Parameters

<ParamField path="options.customerId" type="string">
  Optional fallback `customerId` used when `openCustomerPortal`/`createCustomerPortalSession` are called without `customerId`.
</ParamField>

## Returns

<ParamField path="createCustomerPortalSession" type="(body?) => Promise<CreateCustomerPortalResponse>">
  Creates a portal session and returns `{ url }`.
</ParamField>

<ParamField path="openCustomerPortal" type="(body?) => Promise<CreateCustomerPortalResponse>">
  Creates a portal session, then redirects the browser to Stripe Customer Portal.
</ParamField>

## Body fields

<ParamField path="customerId" type="string">
  Optional customer override. If omitted, the hook uses `options.customerId` or your backend `identifyCustomer`.
</ParamField>

## Example

```tsx theme={null}
import { useCustomerPortal } from "priceos/react";

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

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

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