Checking Consent

Read consent state from the store — check individual categories, logical conditions, and the full consent object.

has(condition)

Check if a consent condition is met. Accepts a simple category name or a logical expression.

Simple Category Check

Logical AND

Require multiple categories to all be granted:

Logical OR

Require at least one category to be granted:

Logical NOT

Check that a category is NOT granted:

Nested Conditions

Combine conditions for complex logic:

hasConsented()

Check if the user has made any consent decision at all (accepted or declined). Returns false if the user hasn't interacted with the consent UI yet.

getDisplayedConsents()

Get the list of consent categories that should be displayed in the UI. This returns the full ConsentType objects including name, title, and description.

consents

The raw consent state object — a Record<string, boolean> mapping category names to their consent status.

React to consent changes in real time: