Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bite-consent

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bite-consent

BitConsent is a lightweight React library for managing cookie consent in web applications. Easily integrate a customizable cookie banner with options to view the privacy policy or accept cookies with a single click.

  • 0.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Bite Consent is a lightweight React library for managing cookie consent views with customizable descriptions and actions. It provides an easy way to implement cookie consent functionality in your React applications while ensuring compliance with privacy regulations.

Screenshot 2024-04-27 at 18 43 55

Features

  • Simple integration with React applications
  • Customizable cookie consent banner with description and actions
  • Built-in actions for "Got it" and opening the privacy policy
  • Lightweight and easy to use

Installation

You can install Bite Consent via npm or yarn:

npm install bite-consent

or

yarn add bite-consent

Usage

To use Bite Consent in your React application, you can now also use the useBiteConsent hook:

import React from 'react'
import { useBiteConsent } from 'bite-consent'

function App() {
  const { consentCookie, show, revoke } = useBiteConsent({
    privacyPolicyUrl: 'https://example.com/privacy',
    theme: {
      mode: 'auto'
    }
  })

  return (
    <div className="App">
      <header className="App-header">
        <h1>Welcome to My Website</h1>
      </header>
      <main>{/* Your component content */}</main>
      {consentCookie ? null : <button onClick={show}>Show Consent Banner</button>}
    </div>
  )
}

export default App

BiteConsentOptions

NameTypeDefaultDescription
privacyPolicyUrlstringundefinedThe URL to your privacy policy. Required.
textstringHey there! We use cookies to keep things running smoothly on our website and to get to know you better. It helps us make your time here as awesome as possible! ❤️Custom text to display in the consent banner.
visibilityauto | visible | hiddenautoSpecifies the visibility of the consent banner. auto displays the view based on the availability of the consent cookie, whereas visible displays and hidden hides it.
positionPosition | CustomPositionbottom-leftSets the position of the consent view on the page. See below for details.
cookieConfigCookieConfig-Configuration options for consent cookies. See below for details.
themeTheme-Theme object containing color configurations for the consent view. See below for details.
onAcceptfunction() => voidA function to be called when the user accepts the cookie policy.

Position

TypeDescription
top-leftPositions the element at the top left corner.
top-rightPositions the element at the top right corner.
bottom-leftPositions the element at the bottom left corner.
bottom-rightPositions the element at the bottom right corner.

CustomPosition

PropertyTypeDescription
topnumber | stringThe distance from the top of the container. Accepts number or CSS string.
leftnumber | stringThe distance from the left of the container. Accepts number or CSS string.
rightnumber | stringThe distance from the right of the container. Accepts number or CSS string.
bottomnumber | stringThe distance from the bottom of the container. Accepts number or CSS string.

CookieConfig

PropertyTypeDescription
namestringThe name or identifier of the consent cookie.
maxAgenumberThe maximum age of the consent cookie in seconds.
expiresDateThe expiration date of the consent cookie.
pathstringThe path within the website's domain for which the cookie is valid.
domainstringThe domain for which the cookie is valid.
securebooleanIndicates if the cookie should only be sent over secure connections.
sameSiteStrict | Lax | NoneThe SameSite attribute of the consent cookie.

Theme

The theme object allows customization of the colors used in the consent banner.

PropertyTypeDescription
modeThemeModeThe theme mode.
lightColorSetColor configurations for light mode.
darkColorSetColor configurations for dark mode.

ColorSet Properties:

  • background: Background color of the consent banner.
  • text: Text color of the consent banner.
  • shadow: Box shadow of the consent banner.
  • primaryActionBackground: Background color of primary action buttons.
  • primaryActionHoverBackground: Background color of primary action buttons on hover.
  • primaryActionText: Text color of primary action buttons.
  • secondaryActionBackground: Background color of secondary action buttons.
  • secondaryActionText: Text color of secondary action buttons.
  • secondaryActionHoverBackground: Background color of secondary action buttons on hover.

License

Bite Consent is released under the MIT License.

Keywords

FAQs

Package last updated on 02 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc