Skip to main content
Introducing packages.sweber.dev
Documentation menuHooks

Hooks

React hooks for reading and changing consent.

useConsent()

Returns the current snapshot plus actions.

FieldType
readyboolean: the stored decision has been read
needsConsentboolean: no valid decision, the banner is shown
decisionConsentState | null
categories, serviceseffective 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