react-lgpd-consent - v0.4.4
    Preparing search index...

    react-lgpd-consent πŸͺ

    A React library for cookie consent management compliant with Brazil's LGPD.

    NPM Version Downloads License Storybook
    TypeScript Ready React 18+ Next.js Compatible
    Coverage Bundle Size Node Version

    Installation β€’ Basic Usage β€’ πŸ“š Quickstart β€’ Documentation β€’ Contributing

    Quickstart

    Start here: follow the Quickstart guide (QUICKSTART.en.md) for step-by-step setup, TypeScript examples, props summary and MUI integration β€” recommended for new users.


    npm install react-lgpd-consent @mui/material @emotion/react @emotion/styled js-cookie
    

    Peer dependencies: react, react-dom, @mui/material and js-cookie.


    Wrap your app with ConsentProvider (minimal example):

    import { ConsentProvider } from 'react-lgpd-consent'

    export default function App() {
    return (
    <ConsentProvider categories={{ enabledCategories: ['analytics'] }}>
    <YourApp />
    </ConsentProvider>
    )
    }
    • For full guides, TypeScript examples, props table and integrations see:
    • QUICKSTART.en.md (recommended)
      • New in v0.4.0: customCategories support β€” see the β€œCustom categories (customCategories)” section in the Quickstart.
      • New in v0.4.1: native integrations for Facebook Pixel, Hotjar, Mixpanel, Clarity, Intercom, and Zendesk β€” see INTEGRACOES.md.
      • Tip: set designTokens.layout.backdrop: 'auto' for a theme-aware blocking banner backdrop.
      • Auto-config of categories: the library detects required categories from integrations and surfaces toggles even if you forgot to enable them (initial value is always rejected). We still recommend explicitly listing them in categories.enabledCategories for clarity.
      • Non-blocked Policy/Terms pages: if policyLinkUrl and/or termsLinkUrl point to the current page, the blocking overlay is not applied β€” ensuring readability of these pages.
    • Docs / API
    • LGPD Compliance
    • Integrations

    In development, the library prints a guidance panel in the console to help you configure correctly:

    • Warns when using default categories; suggests making them explicit
    • Lists active categories and which ones require a UI toggle
    • Detects integrations that require categories and suggests enabling them
    • Flags excessive number of categories (UX)
    • Highlights Brazilian LGPD best practices: opt-out by default, clear policy, consent logging, retention
    • Silenced in production; SSR-safe
    • Custom categories support: setPreference and ScriptIntegration.category now use string instead of Category
    • Minimal impact: Code using literal strings continues working without changes
    • Migration guide: See CHANGELOG.md for complete details

    1. Open an Issue for bugs or feature requests.
    2. Follow DEVELOPMENT.md to submit a PR.

    MIT β€” see the LICENSE file.