Skip to main content
Version: 2.xx.xx

<CanAccess>

<CanAccess /> is a wrapper component that uses useCan to check for access control. It takes the parameters that can method takes and also a fallback. It renders its children if the access control returns true and if access control returns false renders fallback if provided.

<CanAccess
resource="posts"
action="edit"
params={{ id: 1 }}
fallback={<CustomFallback />}
>
<YourComponent />
</CanAccess>

API Reference

Properties

PropertyDescriptionTypeDefault
resource
Required
Resource name for API data interactionsstring
action
Required
Intenden action on resourcestring
paramsParameters associated with the resourceany
fallbackContent to show if access control returns falseReactNode