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-accessRenders children when the current user may perform an action on a resource, optionally scoped to a record.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| accessDenied | ReactNode | — | Rendered when access is denied. Defaults to `null`. |
| action | string | — | The action to check (`'list' | 'create' | 'edit' | 'show' | 'delete'` or custom). |
| children | ReactNode | — | Rendered when access is granted. |
| loading | ReactNode | — | Rendered while the access check is pending. Defaults to `null`. |
| record | unknown | — | Optional record the grant is scoped to (record-level predicates). |
| resource | string | — | The resource to check (e.g. `'posts'`). |