Skip to content

whodinner/cookie-consent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

🍪 cookie-consent

A minimalist, ethical cookie consent component for React + TypeScript.
No tracking. Just a clean banner and real user choice — only when you need it.


Features

  • ✅ One self-contained .tsx file
  • ✅ 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

📦 Installation

This is a standalone component — just copy the single CookieConsent.tsx file into your project.

🧠 Why This Matters

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.


🛡️ Legal Notice

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

About

A lot of people forget to add a cookie consent banner to their websites which is a lot of times, the law. Frameworks like React/Typescript don't have this built in by default. This short piece of code is to add a simple banner to stay legally compliant.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors