@payload-solutions/consent-react
v0.1.0
Published
React bindings for Payload Consent: provider, hooks, ConsentGate, consent-gated script loading, Google Consent Mode v2 script and Next.js server helpers.
Downloads
17
Maintainers
Readme
@payload-solutions/consent-react
React bindings for Payload Consent.
<ConsentProvider config initialCookie>— client provider; pass the server-read cookie for a flash-free first render.useConsent(),useCategory(key),useHasConsent(expr)— state and actions.<ConsentGate category="marketing" fallback={…}>— render only when granted.<ConsentModeScript config cookie />— inline Google Consent Mode v2 defaults for<head>(Server Component friendly).<ManageConsentButton />— reopen the preferences dialog from the footer.@payload-solutions/consent-react/next—readConsent(await cookies(), config)for Server Components and route handlers.
UI: install the shadcn registry block, which copies a banner, a preferences dialog and a footer link into your project:
npx shadcn@latest add https://payload.solutions/r/consent-banner.jsonThe source of that block lives in registry/ of this package.
MIT © Payload Solutions.
