shadcn Components
Copy-to-install Wocha auth components for shadcn/ui projects.
@wocha/shadcn provides Wocha authentication components designed for shadcn/ui projects. Components are installed as source files into your codebase — you own the markup and can customise it with Tailwind.
For pre-built, themed components with a CSS variable system, see @wocha/ui. For headless hooks only, see @wocha/react.
How it differs from @wocha/ui
@wocha/shadcn | @wocha/ui | |
|---|---|---|
| Distribution | Copy-paste via shadcn CLI or manual copy | npm package with bundled CSS |
| Styling | shadcn primitives + your Tailwind theme | .wocha- scoped CSS + WochaThemeProvider |
| Customisation | Edit copied source files directly | appearance props and theme variables |
| Composition API | Not included (simpler surface) | UserButton.Action, UserProfile.Page, etc. |
| Best for | Teams already using shadcn/ui | Teams wanting turnkey auth UI |
Both packages use the same @wocha/react hooks under the hood.
Prerequisites
- shadcn/ui — run
npx shadcn@latest initin your project @wocha/react— install and configureWochaProvider(or@wocha/nextjsfor App Router)- Base shadcn components — install primitives before Wocha components:
Set apiUrl in your provider config for profile management, organisation APIs, and permission checks.
Installation
shadcn CLI
Add the Wocha registry to components.json:
Install individual components:
The CLI installs shadcn registryDependencies (e.g. button, card) automatically and copies Wocha source to components/wocha/.
Manual copy
Adjust @/components/ui/* imports if your path aliases differ.
Quick start
Component reference
WochaSignIn / WochaSignInForm
Sign-in card with email/password fields and optional social provider buttons. Submits trigger the hosted Wocha OAuth flow.
| Prop | Type | Default | Description |
|---|---|---|---|
showSocial | boolean | true | Show Google and GitHub buttons |
onSuccess | () => void | — | Called after successful sign-in |
className | string | — | Additional card classes |
WochaSignInForm is an alias that re-exports WochaSignIn.
WochaSignUp / WochaSignUpForm
Sign-up card that starts the hosted registration flow.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional card classes |
WochaUserButton
Compact avatar dropdown with user info and sign-out.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional trigger classes |
WochaUserMenu
Avatar dropdown with display name, profile link, optional settings link, and sign-out.
| Prop | Type | Default | Description |
|---|---|---|---|
profileUrl | string | "/account" | Link for profile menu item |
settingsUrl | string | — | Optional settings link |
className | string | — | Additional trigger classes |
WochaOrgSwitcher
Organisation selector dropdown. Hidden when the user belongs to a single organisation.
| Prop | Type | Default | Description |
|---|---|---|---|
getOrgLabel | (orgId: string) => string | — | Map org IDs to display names |
className | string | — | Additional button classes |
WochaAuthGuard
Route protection wrapper. Without permission, renders children only when authenticated. With permission, delegates to SpiceDB via Protect.
| Prop | Type | Default | Description |
|---|---|---|---|
permission | PermissionCheck | — | SpiceDB permission required |
loadingFallback | ReactNode | — | Shown while session loads |
fallback | ReactNode | — | Shown when unauthenticated or denied |
children | ReactNode | — | Protected content |
WochaMfaSetup
TOTP MFA enrollment wizard with backup codes. Uses the Account API via useMfa.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional card classes |
WochaUserProfile
Card-based profile management with Profile, Security, and Sessions tabs. Uses useProfile, useSessions, and useMfa from @wocha/react.
| Prop | Type | Default | Description |
|---|---|---|---|
passwordSettingsUrl | string | — | Hosted password change URL |
fallback | ReactNode | — | Shown while loading |
className | string | — | Additional card classes |
Requires accountApiUrl or apiUrl in your provider config.
WochaOrgProfile
Organisation management card with Overview, Members, and Settings tabs.
| Prop | Type | Default | Description |
|---|---|---|---|
orgId | string | active org | Organisation to manage |
apiUrl | string | from config | Customer API base URL |
fallback | ReactNode | — | Shown while loading |
className | string | — | Additional card classes |
WochaCreateOrg
Form to create a new organisation via the Customer API.
| Prop | Type | Default | Description |
|---|---|---|---|
apiUrl | string | from config | Customer API base URL |
onSuccess | (org) => void | — | Called after creation |
onError | (error) => void | — | Called on failure |
afterCreateUrl | string | — | Redirect after success |
className | string | — | Additional card classes |
WochaShow
Conditional render component matching @wocha/ui's Show. Supports signed-in/out states, role checks, permission checks, and custom predicate functions.
| Prop | Type | Default | Description |
|---|---|---|---|
when | ShowWhen | — | Condition to evaluate |
fallback | ReactNode | — | Shown when condition is false or loading |
children | ReactNode | — | Content when condition is true |
ShowWhen accepts "signed-in", "signed-out", { permission: string }, { role: string }, or a predicate function.
Customisation
After installation, components live in components/wocha/. Because you own the source:
- Edit JSX and Tailwind classes directly
- Swap shadcn primitives (e.g. replace
Cardwith a custom wrapper) - Add or remove fields, sections, and menu items
Theme changes via shadcn's globals.css CSS variables (--primary, --radius, etc.) apply automatically to installed components.
Next.js guidance
shadcn components import only from @wocha/react — they do not require @wocha/ui. For Next.js App Router:
- Install
@wocha/nextjsand configure the OAuth BFF handler - Wrap your app with
WochaSessionProviderfrom@wocha/nextjs/client - Pass
apiUrlto the session provider for Customer API and permission features - Install shadcn Wocha components as usual — no additional bridge is needed
Server Components cannot use these components directly (they are "use client"). Import them in Client Components or pages that render client boundaries.
Registry development
To rebuild the registry after changing component source:
This runs shadcn build and outputs item JSON files to registry/.
Learn more
- UI Components (
@wocha/ui) — pre-built themed components - React SDK — headless hooks
- Next.js SDK — server-side OAuth BFF
- Component architecture