npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

heroui-cookie-consent

v0.1.0

Published

Cookie consent component for React 19 and HeroUI

Downloads

1

Readme

HeroUI Cookie Consent

A modern, customizable cookie consent component for React 19 and HeroUI.

Cookie consent modal

Features

  • 🚀 Built for React 19 and HeroUI v2
  • 🌐 Internationalization support with react-i18next
  • 🌙 Dark/Light mode compatibility
  • 📱 Responsive design
  • 🎨 Customizable styling and placement
  • 📦 Small bundle size

Installation

npm install heroui-cookie-consent

Requirements

This package has peer dependencies on:

  • React >= 19.0.0
  • HeroUI v2 (beta for React 19 support)
  • react-i18next >= 15.0.0
  • i18next >= 24.0.0

Basic Usage

import React from 'react';
import ReactDOM from 'react-dom/client';
import { CookieConsentProvider, CookieConsent } from 'heroui-cookie-consent';
import { Provider as HeroUIProvider } from './your-heroui-provider'; // Import your HeroUI provider

// Setup i18next with your configuration (optional)
import './i18n';

ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <HeroUIProvider>
      <CookieConsentProvider>
        <CookieConsent />
        <App />
      </CookieConsentProvider>
    </HeroUIProvider>
  </React.StrictMode>
);

Advanced Usage

Customization Options

<CookieConsent 
  needCookieConsent={true} // Set to false to disable the consent popup
  cookiePolicyUrl="/privacy-policy" // URL to your cookie policy page
  modalPlacement="bottom" // "bottom", "top", or "center"
/>

Custom Handlers

<CookieConsentProvider
  onAccept={() => {
    // Initialize analytics services here
    console.log('Cookies accepted');
  }}
  onReject={() => {
    // Handle cookie rejection
    console.log('Cookies rejected');
  }}
  localStorageKey="my-app-cookie-consent" // Custom localStorage key
>
  <CookieConsent />
  <App />
</CookieConsentProvider>

Using Cookie Consent Status in Components

import { useCookieConsent } from 'heroui-cookie-consent';
import { useEffect } from 'react';

function AnalyticsComponent() {
  const { cookieConsent, resetCookieConsent } = useCookieConsent();
  
  useEffect(() => {
    if (cookieConsent === 'accepted') {
      // Initialize analytics
      console.log('Loading analytics...');
    }
  }, [cookieConsent]);
  
  return (
    <div>
      <p>Cookie consent status: {cookieConsent}</p>
      <button onClick={resetCookieConsent}>Reset Cookie Consent</button>
    </div>
  );
}

Internationalization

The component automatically looks for these translation keys:

{
  "cookie-consent": "We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking <strong className=\"font-semibold\">\"Accept All\"</strong>, you consent to the use of ALL the cookies. Please read our",
  "cookie-policy": "Cookie Policy.",
  "accept-all": "Accept All",
  "reject": "Reject",
  "cookie-consent-title": "Cookies policy"
}

If these keys are present in your i18next setup, they'll be used for translations. Otherwise, the component falls back to the English defaults.

Adding to your i18n files

Example with English and French:

// en.json
{
  "cookie-consent": "We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking <strong className=\"font-semibold\">\"Accept All\"</strong>, you consent to the use of ALL the cookies. Please read our",
  "cookie-policy": "Cookie Policy.",
  "accept-all": "Accept All",
  "reject": "Reject",
  "cookie-consent-title": "Cookies policy"
}

// fr.json
{
  "cookie-consent": "Nous utilisons des cookies sur notre site Web pour vous offrir l'expérience la plus pertinente en nous souvenant de vos préférences et de vos visites répétées. En cliquant sur <strong className=\"font-semibold\">\"Tout accepter\"</strong>, vous consentez à l'utilisation de TOUS les cookies. Veuillez lire notre",
  "cookie-policy": "Politique de cookies.",
  "accept-all": "Tout accepter",
  "reject": "Refuser",
  "cookie-consent-title": "Politique de cookies"
}

Props Reference

CookieConsent Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | needCookieConsent | boolean | true | Whether to show the cookie consent modal | | cookiePolicyUrl | string | "#" | URL to your cookie policy page | | modalPlacement | "bottom" | "top" | "center" | "bottom" | Position of the modal on the screen |

CookieConsentProvider Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | children | ReactNode | - | Child components | | onAccept | () => void | undefined | Function called when cookies are accepted | | onReject | () => void | undefined | Function called when cookies are rejected | | localStorageKey | string | "cookie-consent-status" | Key used for localStorage |

License

MIT © Ronan LE MEILLAT