This guide covers plain React apps — bundled with Vite or Create React App (CRA). If you’re using Next.js, follow our Next.js guide. If you’re using Remix, follow our Remix guide.Documentation Index
Fetch the complete documentation index at: https://docs.cookiechimp.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Before you start: have your CookieChimp Account ID ready (replace
YOUR_ACCOUNT_ID in the snippets below). If you're testing on localhost, add localhost to Additional Domains in your Account Settings — otherwise the banner won't show locally.How do I install CookieChimp in a Vite + React app?
Add the script tag toindex.html (at the project root) inside <head>, before any module scripts so it loads first:
How do I install CookieChimp in a Create React App?
Add the script tag topublic/index.html inside <head>, before any other scripts:
<script> in <head> runs before React mounts.
How do I handle client-side routing (React Router)?
If your app uses React Router (v6+), pages don’t reload on navigation — they swap components. CookieChimp needs to know about route changes so it can re-evaluate which scripts to allow. Create a small component that listens to location changes and re-injects the CookieChimp script. We skip the first render because the static<script> tag in index.html has already loaded CookieChimp on initial page load.
How do I add a Privacy Trigger container?
Place a<div> with the ID cookiechimp-container somewhere in your layout that doesn’t unmount on navigation — typically your root layout or App.tsx:
How do I check consent status in code?
Listen for thecc:onConsented event (fires once when consent has been given) and cc:onUpdate (fires when the user changes their preferences).
Replace
"Google Analytics" and "analytics" with the exact service and category names you configured in CookieChimp.Troubleshooting
- Banner shows on first load but not after navigation — make sure
CookieChimpReinitis mounted inside<BrowserRouter>. - Privacy Trigger disappears — keep
#cookiechimp-containerin a layout component that stays mounted across routes.
- Banner doesn't appear at all — confirm
localhost(or your domain) is in Additional Domains in Account Settings. - Enable Debug mode in the CookieChimp dashboard and check the browser console for logs.