Can
Shows an action only to members who hold a permission key; the checks of one render share one round trip. It loads its data on the server through the block's client.
pnpm dev:example) to see it.Add the components
terminal npx shadcn addInstall the glue
Install the block with
npx better-supabase add access. The glue items are copied into your app, so edit them as you need.None: the page calls the block's client on the server.
Write the component
React and shadcn
View in the exampletask-import-action.tsx "use client"; import { Can } from "better-supabase/blocks/access/react"; import { permissions } from "@/lib/supabase/blocks.generated"; import { TaskImportDialog } from "./task-import-dialog"; /** * The import button, for members with `imports.manage` in the active * organization. The `<Can>` checks of one render share one `my_permissions` * call; the import action checks the key again on the server. */ export function TaskImportAction({ projectId }: { projectId: string }) { return ( <Can permission={permissions.imports.manage}> <TaskImportDialog projectId={projectId} /> </Can> ); }