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
Automatic (recommended)
Manual
Appearance
Customize the visual appearance of all BillingOS components through theappearance prop:
AppearanceConfig
AppearanceVariables
Accessing the context
Use theuseBillingOS hook to access the SDK client from any component: