react-cookienotice

A lightweight & customizable cookie banner for your React App

Usage no npm install needed!

<script type="module">
  import reactCookienotice from 'https://cdn.skypack.dev/react-cookienotice';
</script>

README

Preview Light

react-cookienotice

A lightweight & customizable cookie banner for your React App

NPM JavaScript Style Guide codecov npm-publish downloads live-preview

  • ๐Ÿƒ No dependency, full self-made package (1.3 kB - BundlePhobia)
  • ๐Ÿ“ฑ Mobile first & responsive
  • โš™๏ธ Customizable with several props
  • ๐Ÿ• Very fast setup (less than 1 minute)
  • ๐Ÿงช Tested with functionals tests
  • ๐ŸŒ™ Dark mode based on system settings
  • ๐ŸŒŽ Translated in French & English (create issue for more languages)

Install

Yarn

yarn add react-cookienotice

npm

npm i --save react-cookienotice

Usage

import React from 'react'

import CookieNotice from 'react-cookienotice'
import 'react-cookienotice/dist/index.css'

const Example = () => <CookieNotice />

export default Example

Props

All props are optionals

Key Type Description Default value
acceptButtonLabel string Edit the "Accept" button label Accept
readMoreButtonLabel string Edit the "Read more" button label Read more
readMoreButtonLink string Edit the "Read more" button link http://aboutcookies.org/
readMoreButtonOpenInNewTab boolean Open the "Read more" button link in a new tab true
cookieTextLabel string Main cookie notice label This website uses cookies to improve your browsing experience.
cookieExpiration number Days after cookie expires and user should reaccept cookies 30
cookieName string The name of the cookie that saves the user consent allow-cookies
onAcceptButtonClick Function A callback function called after the "Accept" button click -

License

MIT ยฉ xavierbriole