Feature Flags Example
A React example that models feature access as typed permissions
Purpose
examples/feature-flags shows that Permix is not limited to classic CRUD authorization. You can also model feature access, experiments, and progressive rollouts as typed permission checks.
What it demonstrates
- feature flags represented as entities and actions
- early-return UI gating for hidden features
- imperative checks before calling protected client logic
- a tiny ruleset that reads like product rollout configuration
Core idea
The example treats flags such as newUI or experimentalAPI as permissions:
betaFeatures: {
newUI: true,
experimentalAPI: false,
}That lets the component hide the whole new UI until the flag is enabled:
if (!check('betaFeatures', 'newUI')) {
return null
}Run it
cd examples/feature-flags
pnpm devKey files
src/lib/permix.ts: feature-flag rules and setup helpersrc/hooks/use-permissions.ts: React wrapper aroundusePermixsrc/App.tsx: gated UI and guarded client-side action
When to use it
Use this pattern when the question is "should this user see or use this feature?" rather than "can this user mutate this record?".