ForReact logoReact

Cookie consent for React

A React package that blocks trackers until users consent, with typed hooks to gate your own code.

Most React cookie-consent libraries only store a choice in a cookie; they do not stop third-party scripts from loading. ConsentStack ships a React package that blocks trackers until the user consents and gives you hooks to gate your own scripts, with GDPR, CCPA, and 70+ regulations handled for you.

Why ConsentStack on React

  • A real consent layer, not just a cookie: third-party scripts are blocked until consent.
  • Typed hooks (useConsent, useConsentValue) to conditionally load analytics and marketing code.
  • Regulation coverage and geo-detection are handled for you, so you do not maintain rules in your app.
  • Pixel-perfect brand matching, so the banner looks built into your React site, never bolted on.

Install in React

terminal
npm install @consentstack/react
app/layout.tsx
import { ConsentStack } from "@consentstack/react"

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        {children}
        <ConsentStack siteKey="YOUR_SITE_KEY" />
      </body>
    </html>
  )
}

Replace YOUR_SITE_KEY with the site key from your ConsentStack dashboard.

Render <ConsentStack /> once near the root of your app. Use the useConsent hook to gate analytics or marketing code on a category.

Common questions

100+ happy customers

AN
ML
LP
DM
JT

Ship consent on React. In minutes.

Scan your site free to see what is firing before consent, then turn on real blocking from one install.

Get started free