A minimalist, ethical cookie consent component for React + TypeScript.
No tracking. Just a clean banner and real user choice — only when you need it.
- ✅ One self-contained
.tsxfile - ✅ Written in React + TypeScript
- ✅ Stores consent in
localStorage - ✅ Includes
useCookieConsent()hook (in the same file) - ✅ Only shows banner when needed (custom logic supported)
- ❌ No external dependencies
- ❌ No third-party scripts or trackers
This is a standalone component — just copy the single CookieConsent.tsx file into your project.
You may be legally or ethically required to ask for consent if your site uses:
- Google Analytics
- Facebook Pixel
- Embedded YouTube, maps, or media
- Any third-party cookies or local tracking
This component doesn’t track anything. It simply respects your user's agency and gives you a place to ask for consent before loading third-party tools.
This component helps you delay scripts or tracking until the user explicitly consents. It’s a step toward compliance with:
- GDPR (EU)
- CCPA/CPRA (California)
- PECR (UK)
You are responsible for:
- Disclosing data practices
- Respecting user choices
- Ensuring legal compliance for your region