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:

  1. Consent state is updated in the store
  2. UI closes (activeUI → 'none')
  3. Consent is saved to localStorage and cookie
  4. If consent was revoked and reloadOnConsentRevoked is true, the page reloads
  5. Otherwise, scripts/iframes/network blocker are updated
  6. 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: