Skip to content
On this page


This helper function may be used with a DataResource to determine its authorizations.


function can(resource: Authorizable, action: Action): boolean

can takes two arguments: an object that implements Authorizable and a string that's an action from this Authorizable.

Data objects that extend DataResource and transformed to TypeScript interfaces implement Authorizable.

To learn more about generating TypeScript interfaces, read the TypeScript setup and the authorization documentation.


This example assumes that a ChirpData object extending DataResource is defined and converted to a TypeScript interface.

<script setup lang="ts">
import { can } from 'hybridly' 

const $props = defineProps<{
  chirp: App.Data.ChirpData  

const canComment = can($props.chirp, 'comment')