Setting Consent
Save, update, and reset consent preferences with setConsent(), setSelectedConsent(), and saveConsents().
saveConsents(type)
The primary way to persist consent. Accepts one of three strategies:
What happens when you call saveConsents:
- Consent state is updated in the store
- UI closes (activeUI → 'none')
- Consent is saved to localStorage and cookie
- If consent was revoked and
reloadOnConsentRevokedis true, the page reloads - Otherwise, scripts/iframes/network blocker are updated
- Consent is synced to the backend API
setConsent(name, value)
Updates a single consent category AND automatically saves it. Use this for simple one-off consent changes:
setSelectedConsent(name, value)
Updates the selection state without saving. This is what dialog toggles use - the user can flip toggles without committing until they click "Save":
resetConsents()
Resets all consent preferences to their default values and clears stored consent:
Accept All / Reject All Patterns
Common patterns for banner buttons: