Fejlesztőknek
Kezdj bele
Témák/Theme SDK/Modules/consent/Hooks

Hooks

Ez az oldal még csak angolul érhető el.

The hooks of @poltura/theme-sdk/consent.

Ezen az oldalon
import { … } from '@poltura/theme-sdk/consent';

useConsent

The shopper's cookie consent.

useConsent(): ConsentState

It 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>
  );
}
Utoljára frissítve