Skip to main content
Import React integrations from @crxbase/payments/react. The root @crxbase/payments import remains available for framework-independent code such as a background script.

Set up the provider

Wrap your popup, options page, or other React interface with CrxbaseProvider:
The provider connects its children to your crxbase project and loads the current user. All components inside it share the same user state. If projectId changes, the provider loads the user for the new project.

Access the client

useCrxbase gives you access to the project client. Use it to retrieve tiers or open crxbase pages:
For a custom pricing interface, call await useCrxbase().getTiers() to retrieve your tiers and prices.

Read user state

useUser returns the shared current-user state:
Use useCrxbase and useUser only inside CrxbaseProvider.

Render by user state

Show displays its children when when matches the user’s current state. It supports signed-in, signed-out, and paid, with an optional fallback:
When you need the user object, use render instead of children. For signed-in and paid, the function receives the signed-in user and TypeScript knows the user exists:
Use either children or render, not both. render is available only for signed-in and paid because signed-out users do not have a user object. Nesting lets you show different messages to signed-out and signed-in unpaid users. While the user’s status is loading or unavailable, Show displays neither its content nor fallback. Use useUser if you want to display a loading or error state.
Show only controls what appears in the interface. It does not protect features or sensitive data. Enforce access in your API or server-side code.