Skip to content
rw3iss Auth

RoleGate

atom @rw3iss/auth-client/preact/atoms/RoleGate framework-adapters/preact/components/atoms/RoleGate.tsx ↗

Render children only if the current user has one of the listed roles. Reads user.roles from the AuthClient snapshot — no extra network call. The role names match the role-code strings on the server (e.g. “system_admin”, “super_admin”, “org_admin”).

Special-case: a system_admin user always passes (mirrors the server-side gate which treats system_admin as a universal bypass).

Usage

<RoleGate anyOf={[‘system_admin’, ‘super_admin’]}>

Usage

import { RoleGate } from '@rw3iss/auth-client/preact/atoms';
<RoleGate
children={<></>}
/>

Props

NameTypeDescription
childrenComponentChildren(required)
anyOfstring[]
allOfstring[]
fallbackComponentChildren
clientAuthClient