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-lgpd-consent

v0.9.0

Published

Biblioteca de consentimento LGPD, integrações nativas e sistema extensível para React.

Downloads

688

Readme

react-lgpd-consent 🍪

Gerenciamento de consentimento de cookies em conformidade com a LGPD — pacote agregador que re-exporta os componentes MUI por conveniência. Se você precisa só da lógica headless ou de um bundle menor, prefira @react-lgpd-consent/core ou @react-lgpd-consent/mui conforme o seu caso.

NPM Version Downloads License Coverage


Descrição

react-lgpd-consent é o pacote agregador compatível com versões anteriores (v0.4.x → v0.5.x). Ele re-exporta os componentes prontos em MUI e facilita a migração. Para projetos mais otimizados, considere importar diretamente @react-lgpd-consent/core (headless) ou @react-lgpd-consent/mui/ui (apenas UI, sem re-export do core).

Principais características:

  • Banner de cookies, modal de preferências e botão flutuante prontos (MUI)
  • Carregamento condicional de scripts com base no consentimento
  • SSR-safe (compatível com Next.js / Remix)
  • Eventos auditáveis (consent_initialized, consent_updated)

Instalação

Instale o pacote e as peer-dependencies se necessário:

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

Observação: react-lgpd-consent é o agregador (re-exporta @react-lgpd-consent/mui). Para otimizar bundle, importe apenas o pacote que você precisa.


Início rápido

Exemplo mínimo (mantém compatibilidade com v0.4.x):

import React from 'react'
import { ConsentProvider, useConsent } from 'react-lgpd-consent'

export default function App() {
  return (
    <ConsentProvider categories={{ enabledCategories: ['analytics', 'marketing'] }}>
      <YourApp />
    </ConsentProvider>
  )
}

function YourApp() {
  const { preferences, setPreference } = useConsent()

  return (
    <div>
      <button onClick={() => setPreference('marketing', true)}>Aceitar Marketing</button>
    </div>
  )
}

Para carregar scripts condicionados ao consentimento:

import { ConsentScriptLoader, COMMON_INTEGRATIONS } from 'react-lgpd-consent'

function Analytics() {
  return (
    <ConsentScriptLoader
      integrations={[
        COMMON_INTEGRATIONS.googleAnalytics({ measurementId: 'GA_MEASUREMENT_ID' }),
      ]}
    />
  )
}

🆕 Novidades v0.7.0

Callbacks de Lifecycle (#68)

<ConsentProvider
  onConsentInit={(state) => console.log('Init:', state)}
  onConsentChange={(current, prev) => console.log('Changed:', current)}
  onAuditLog={(entry) => fetch('/api/audit', {
    method: 'POST',
    body: JSON.stringify(entry)
  })}
>

Presets ANPD (#70)

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

const categories = createAnpdCategoriesConfig({
  include: ['analytics', 'marketing']
})

Auditoria (#60)

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

const audit = createConsentAuditEntry(state, {
  action: 'update',
  consentVersion: '1'
})

📖 Documentação completa: API.md | TROUBLESHOOTING.md


Pacotes (monorepo v0.5.x)

| Pacote | Descrição | |---|---| | @react-lgpd-consent/core | Lógica headless (sem UI) — recomendado para UI customizada | | @react-lgpd-consent/mui | Componentes prontos em MUI | | react-lgpd-consent | Agregador (re-exporta MUI) — compatibilidade retroativa |


Documentação e exemplos

  • Quickstart: QUICKSTART.md (tutoriais e exemplos) — veja no repositório
  • API Reference: API.md
  • Integrações: INTEGRACOES.md
  • Storybook: https://lucianoedipo.github.io/react-lgpd-consent/storybook/
  • TypeDoc: https://lucianoedipo.github.io/react-lgpd-consent/docs/

Contribuindo

Leia DEVELOPMENT.md no repositório principal. Fluxo sugerido:

  1. Fork
  2. Branch: git checkout -b feat/minha-feature
  3. Commit: git commit -m "feat: descrição"
  4. Push e abra PR

Antes de criar PR execute a pipeline local sugerida:

npm run type-check
npm test
npm run lint
npm run build
npm run docs:generate

Licença

MIT © Luciano Edipo — veja o arquivo LICENSE.


If you prefer the English version of the README, consult README.en.md in the same package.