can
can(
grants,action,table):boolean
Defined in: packages/permissions/src/can.ts:29
Checks whether a set of resolved grants permits a specific action on a table.
Unlike checkPermissions (which takes a role string and the full permissions
object), can works directly with the user’s resolved grants — the same grants
available in loaders, actions, and client-side via useActions.
Parameters
Section titled “Parameters”grants
Section titled “grants”Grant[]
The user’s resolved permission grants.
action
Section titled “action”The permission action to check (e.g., "create", "read").
object
The Drizzle table object to check against.
Returns
Section titled “Returns”boolean
true if any grant permits the action on the table.
Example
Section titled “Example”import { can } from "@cfast/permissions";
// In a loaderif (!can(ctx.auth.grants, "create", posts)) { throw redirect("/");}
// In a component{can(grants, "update", posts) && <Button>Edit</Button>}