React Example
A React example with object-aware checks and reactive UI updates
Purpose
examples/react is the main non-Next React example. It demonstrates data-aware permissions where the answer depends on the current record, not just on the action name.
What it demonstrates
- React integration with
PermixProviderandusePermix - permission predicates that inspect the checked object
- asynchronous setup after the current user becomes available
Checkcomponent usage next to imperativecheck(...)
Core idea
The edit permission depends on the current post:
edit: post => post?.authorId === user.id,That lets the same user edit some posts but not others, while keeping the check strongly typed.
Run it
cd examples/react
pnpm devKey files
src/lib/permix.ts: typed React Permix instance andCheckcomponentsrc/hooks/permissions.ts: local hook wrappersrc/App.tsx: per-post checks and conditional rendering
When to use it
Use this example when you need object-aware React checks outside Next.js. If you are using App Router, prefer the dedicated Next.js integration guide and the Next examples.