Consent React

React components and hooks for cookie consent, gated scripts and Consent Mode

Community 9 71/wk MIT v0.1.0

Installation

pnpm add @payload-solutions/consent-react

About

Consent React gives React and Next.js frontends the consent state of a Cookie Consent setup for Payload. A provider keeps visitor choices in sync across the page, so banners, preference dialogs and footer links all read the same state. A gate component renders content only after the visitor grants a given category, and scripts can be loaded only once consent is given.

The package also includes Google Consent Mode v2 defaults that render in the page head before any tags fire, so Google tags respect the visitor's choices from the first load. Server-side helpers read the consent cookie in Server Components and route handlers, which avoids a flash of the banner on first render. A ready-made banner, preferences dialog and footer link can be added as a shadcn block.

Package info

Package name
@payload-solutions/consent-react
Latest version
0.1.0
Unpacked size
41 kB
License
MIT
Weekly downloads
71
Last publish
Sep 7, 2026

More from mpresecan

View profile

Schedules one-off, recurring and cron-based actions that run on the Payload job queue

Scaffolds a SaaS project on Payload with database, auth, billing and storage chosen up front

Cookie banner, script gating, legal pages and consent records managed in the admin

Newsletters sent through Resend Broadcasts, with Payload collections as subscriber sources

Triggers Vercel deploy hooks after Payload content changes, with status and rollback

Code-defined transactional emails with admin-editable copy, test sends and a send log

React hook and refresh component for Payload Live Preview in frontend apps

Vue composable that wires a Payload Live Preview into a Vue frontend

React admin bar that puts Payload editing controls on your frontend pages

Client SDK that streams live Payload draft edits into a frontend preview

Renders Lexical rich text content from Payload in Astro sites

Manifest, linter and Payload block generator for a design system's components