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

react-cookienotice

v7.0.1

Published

A lightweight & customizable cookie banner for your React App

Readme

react-cookienotice

A lightweight & customizable cookie banner for your React App

Preview Light

npm npm@next coverage minzipped downloads storybook

  • 🍃 No dependency, full self-made package (Bundlephobia)
  • 📱 Mobile first & responsive
  • ⚙️ Customizable with several props
  • ⏱️ Very fast setup (less than 1 minute)
  • 🧪 Tested with unit & functional tests
  • 🌙 Dark mode based on system settings
  • 🌎 Translated in Deutsch, English, Español, Français, Italiano, 한국인, Occitan & 中文 (create issue or submit pull request for more languages)

Install

npm

npm i --save react-cookienotice

Yarn

yarn add react-cookienotice

If you're using a SSR framework like Next.js, see Troubleshooting section.

Usage

import React from 'react'
import { CookieNotice } from 'react-cookienotice'
import 'react-cookienotice/style'

const Example = () => <CookieNotice />

export default Example

Props

All props are optionals.

If you want a "Read More" link, you must set all of the following props:

  • readMoreLabel
  • readMoreLink
  • readMoreInNewTab

| Key | Type | Description | Default value | | ----------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | acceptAllButtonLabel | string | The label for the accept all cookies button. | Accept all (translated in browser language) | | onAcceptAllButtonClick | Function | A callback function to be called when the accept all cookies button is clicked. | - | | declineAllButtonLabel | string | The label for the decline all cookies button. | Decline all (translated in browser language) | | onDeclineAllButtonClick | Function | A callback function to be called when the decline all cookies button is clicked. | - | | customizeButtonLabel | string | The label for the customize cookies button. | Customize (translated in browser language) | | customizeTitleLabel | string | The title for the customize view. | Customize (translated in browser language) | | services | ServiceObject[] | List of services to be customized. | - | | acceptButtonLabel | string | The label for the accept button. | Accept (translated in browser language) | | onAcceptButtonClick | Function | A callback function to be called when the accept cookies button is clicked. The first param returns the checked services. | - | | backButtonLabel | string | The label for the back button. | Back (translated in browser language) | | alwaysActiveLabel | string | The label for the always active services. | Always active (translated in browser language) | | customizeAcceptAllButtonLabel | string | The label for the accept all button in the customize view. | Accept all (translated in browser language) | | customizeAcceptAllTimeout | number | The timeout for the accept all button in the customize view. | 1000 | | titleLabel | string | The title for the cookie banner. | Cookie consent (translated in browser language) | | descriptionLabel | string | The description for the cookie banner. | By clicking Accept, you consent to our website's use of cookies to provide you with the most relevant experience by remembering your cookie preferences. (translated in browser language) | | readMoreLabel | string | The label for the read more link. | - | | readMoreLink | string | The link for the read more label. | - | | readMoreInNewTab | boolean | Whether the read more link should open in a new tab. | - | | placement | PlacementOptions | The placement of the cookie banner. | { vertical: 'bottom', horizontal: 'left' } | | cookieOptions | CookieOptions | Cookie options. | { name: 'hide-notice', value: 'true', expires: 30, secure: false, httpOnly: false, sameSite: 'lax' } |

Troubleshooting

I'm using a SSR framework like Next.js and I have this error on build: document is not defined

For SSR you need to import dynamically the module with next/dynamic using { ssr: false }. This prevents the component from being included on the server, and dynamically loads it on the client-side only.

Create a new file which include the CookieNotice component :

import { CookieNotice } from 'react-cookienotice'
import 'react-cookienotice/style'

export default function CookieBanner() {
  return <CookieNotice />
}

then you can import it wherever the component is used :

import dynamic from 'next/dynamic'

const CookieBanner = dynamic(() => import('./cookie-banner'), { ssr: false })

export default function Home() {
  return <CookieBanner />
}

License

MIT © xavierbriole

Credits

Built with Vite