Documentation menuHooks
Hooks
React hooks for reading and changing consent.
useConsent()
Returns the current snapshot plus actions.
| Field | Type |
|---|---|
ready | boolean: the stored decision has been read |
needsConsent | boolean: no valid decision, the banner is shown |
decision | ConsentState | null |
categories, services | effective consent per id |
mode | "opt-in" | "opt-out" |
hasConsent(id), hasServiceConsent(id) | |
acceptAll(), rejectAll() | |
updateConsent(categories, { services }) | change single categories or services |
setServiceConsent(id, granted) | |
resetConsent() | withdraw the decision, the banner returns |
openPreferences(), closePreferences(), preferencesOpen |
Shortcuts
useHasConsent("statistics"); // boolean
useHasServiceConsent("youtube"); // boolean
useIsAllowed({ service: "youtube" });
usePermitoTranslations(); // resolved texts for custom UIs