Skip to main content

Overview

BillingOSProvider is a React context provider that initializes the BillingOS SDK client and makes it available to all child components and hooks. You must wrap your app with this provider before using any BillingOS components or hooks.

Basic setup

1

Create a session token endpoint

2

Create a providers file

3

Wrap your layout

app/layout.tsx

Props

string
URL to fetch session tokens from your server. The SDK calls this endpoint automatically, stores the token, and refreshes it before expiry. Use this or sessionToken — one is required.
string
A session token string for manual mode. You’re responsible for refreshing the token yourself. Use this or sessionTokenUrl — one is required.
object
Options for token fetching behavior (automatic mode only).
string
Override the customer ID.
string
Customer’s email address.
string
Customer’s display name.
string
Your BillingOS organization ID.
AppearanceConfig
Customize the visual appearance of BillingOS components. See Appearance below.
ReactNode
Content to render while the session token is being fetched.
BillingOSClientOptions
SDK client configuration.
QueryClient
Custom TanStack Query client. If omitted, the SDK creates one internally.
boolean
default:"false"
Enable debug logging.
ReactNode
required
Your app content.

Automatic vs manual tokens

The SDK calls your endpoint, stores the token, and refreshes it before expiry. Zero maintenance.

Manual

You manage token fetching and refresh yourself. Useful if you have a custom auth setup.

Appearance

Customize the visual appearance of all BillingOS components through the appearance prop:

AppearanceConfig

AppearanceVariables

The SDK injects CSS on mount automatically — no separate CSS import needed.

Accessing the context

Use the useBillingOS hook to access the SDK client from any component:

Context values