React SDK
Hooks and headless components for React single-page applications.
@wocha/react provides React hooks and headless components for Wocha authentication in single-page applications. It implements OAuth 2.0 authorisation code with PKCE as a public client.
Installation
pnpm add @wocha/reactOr scaffold with the CLI
npx @wocha/cli init --framework react-spaQuick start
Register your redirect URI in the Console before testing.
Hooks
All hooks must be used inside WochaProvider.
useSession()
useOrg()
Switch organisation context when the user belongs to multiple orgs:
usePermissions()
Check SpiceDB permissions client-side when apiUrl is configured:
Components
Headless components are available for common UI patterns:
For pre-built UI, see @wocha/ui.
Learn more
- React quickstart
- Next.js SDK — for App Router with server-side sessions