Documentation
Debugging
Use decisions and debug helpers to see why UI is hidden, denied, allowed, or not ready.
Debug Hidden UI
When UI is hidden, ask for the decision first. useAccessDecision reads from PermissionProvider. checkPermission is pure and takes the model manually.
Debug Hidden UI
const decision = useAccessDecision("billing.manage");
if (!decision.allowed) {
return <pre>{formatDecision(decision)}</pre>;
}Allowed Decision
A wildcard permission can allow a concrete permission when segment counts match.
Allowed Decision
checkPermission(
{ permissions: ["reports.*"] },
{ permission: "reports.export" },
);
// {
// allowed: true,
// reason: "allowed",
// requested: ["reports.export"],
// matched: ["reports.*"],
// checkedFrom: "wildcard"
// }Denied And Missing Permission
A denied permission includes the requested and missing values. This is the fastest way to see why access was denied.
Denied And Missing Permission
checkPermission(
{ permissions: ["reports.view"] },
{ permission: "billing.manage" },
);
// {
// allowed: false,
// reason: "missing_permission",
// requested: ["billing.manage"],
// missing: ["billing.manage"],
// checkedFrom: "none"
// }Loading Or Not Ready
If PermissionProvider is loading or no model exists yet, decisions return not_ready. Render loading UI or fallback UI explicitly.
Loading Or Not Ready
checkPermission(null, { permission: "reports.view" });
// { allowed: false, reason: "not_ready" }Inspect The Model
inspectAccess summarizes the active model before you debug one permission. formatDecision formats a single decision for logs or developer UI.
Inspect The Model
console.log(inspectAccess(model)); console.log(formatDecision(decision));
