CanAccess

Renders children when the current user may perform an action on a resource, optionally scoped to a record.

Installation

pnpm dlx shadcn@latest add @chelone/can-access

Renders children when the current user may perform an action on a resource, optionally scoped to a record.

Props

PropTypeDefaultDescription
accessDeniedReactNode—Rendered when access is denied. Defaults to `null`.
actionstring—The action to check (`'list' | 'create' | 'edit' | 'show' | 'delete'` or custom).
childrenReactNode—Rendered when access is granted.
loadingReactNode—Rendered while the access check is pending. Defaults to `null`.
recordunknown—Optional record the grant is scoped to (record-level predicates).
resourcestring—The resource to check (e.g. `'posts'`).