WP Kernel API / @wpkernel/ui / usePolicy
Function: usePolicy()
ts
function usePolicy<K>(): UsePolicyResult<K>;
React hook that exposes the kernel policy runtime to UI components.
Components can gate controls with can()
while reacting to the shared policy cache for loading and error states. The hook mirrors the policy enforcement path used during action execution, keeping UI affordances in sync with capability checks. When no policy runtime is present we surface a developer error so plugin authors remember to bootstrap via definePolicy()
.
Type Parameters
K
K
extends Record
<string
, unknown
>
Returns
UsePolicyResult
<K
>