Hooks
The hooks of @poltura/theme-sdk/consent.
On this page
import { … } from '@poltura/theme-sdk/consent';useConsent
The shopper's cookie consent.
useConsent(): ConsentStateIt carries the merchant's banner wording, its look and the actions that record a choice. The host stores the choice in the consent cookie and gates every tracker by it; a theme only draws the choice.
Returns: The consent state and its actions.
Example
import { useConsent } from '@poltura/theme-sdk/consent';
export function CookieSettingsButton() {
const consent = useConsent();
if (!consent.enabled) return null;
return (
<button type="button" onClick={consent.openPreferences}>
{consent.texts.openPreferences || consent.texts.preferencesTitle}
</button>
);
}