Show
Unified conditional render for auth states, roles, and permissions.
The <Show> component conditionally renders children based on authentication state, role, or permission. It is a more flexible alternative to <Protect> with a declarative when prop.
Installation
pnpm add @wocha/ui @wocha/reactOr scaffold with the CLI
npx @wocha/cli init --framework nextjsBasic usage
Props
| Prop | Type | Default | Description |
|---|---|---|---|
when | ShowWhen | — | Condition that must be true to render children |
fallback | ReactNode | — | Rendered when the condition is false or loading |
children | ReactNode | — | Content to render when visible |
ShowWhen values
| Value | Description |
|---|---|
"signed-in" | User is authenticated |
"signed-out" | User is not authenticated |
{ role: string } | User has matching role claim |
{ permission: string } | User has permission in active organisation |
(has) => boolean | Custom predicate with role/permission helpers |
Role and permission examples
Permission checks require apiUrl and an active orgId on the session.
Custom predicate
Framework notes
Works identically in React and Next.js client components. Pair with WochaProvider or WochaSessionProvider.