React
Add Playstack session, account, audience, notification, analytics, and error state to React without treating client providers as security boundaries.
Playstack domain React packages are headless bindings over portable services. They carry safe state through a component tree and expose application-neutral hooks; they do not configure a router, render branded UI, initialize vendor SDKs, or authorize server operations.
Start with the React guide to add session state and an application error boundary.
Available React bindings
| Binding | Core capability | Responsibility |
|---|---|---|
@playstack/auth-react | @playstack/auth | Session state, auth actions, revalidation, and cross-tab synchronization. |
@playstack/accounts-react | @playstack/accounts | Visible-account loading and active-account selection. |
@playstack/errors-react | @playstack/errors | Reporter context and resettable render error boundaries. |
@playstack/analytics-react | @playstack/analytics | Analytics context, reactive consent, and explicit route tracking. |
@playstack/audiences-react | @playstack/audiences | Subscribe and preference-center state with safe public responses. |
@playstack/notifications-react | @playstack/notifications | In-app inbox state, unread counts, pagination, and optimistic mutations. |
The binding accepts an already configured core service or transport. This keeps provider initialization, API origins, consent persistence, and framework routing in the application.
Provider order
A useful default places operational reporting outside stateful product providers:
ErrorsProvider
└── ErrorsBoundary
└── PlaystackAnalyticsProvider
└── PlaystackAuthProvider
├── AccountsProvider when account switching is needed
└── Audience or notification providers where their UI is renderedThis is not a mandatory global provider stack. Mount providers only around the subtrees that consume them, and keep server-derived initial state as narrow as possible.
Security boundary
RequireSession and account-aware navigation prevent confusing client transitions; they do not establish authorization. The server must revalidate authentication, membership, roles, entitlements, and API-key scopes for every protected operation.
Framework composition
Use these same bindings beneath Next.js, another React meta-framework, or a client-rendered application. Router-specific behavior is opt-in: analytics exposes dedicated Pages and App Router helpers, while other routers call analytics.page() after their own completed-navigation signal.
Optional application UI
Chakra, App UI and Admin UI add themes, controlled application compositions and the initial scoped members section. These are independent of auth/backend adoption. The host owns routes, data, mutations and authorization; Next Client Components hold callbacks and the Chakra system. See Application interfaces.