An open API service indexing awesome lists of open source software.

https://github.com/dorsium/gdpr-consent

Lightweight GDPR & Cookie Consent module for Next.js projects. Built by Dorsium.
https://github.com/dorsium/gdpr-consent

cookie-consent dorsium gdpr nextjs privacy react tailwind

Last synced: about 2 months ago
JSON representation

Lightweight GDPR & Cookie Consent module for Next.js projects. Built by Dorsium.

Awesome Lists containing this project

README

          

# @dorsium/gdpr

[![npm version](https://img.shields.io/npm/v/@dorsium/gdpr.svg)](https://www.npmjs.com/package/@dorsium/gdpr)
[![GitHub](https://img.shields.io/github/stars/dorsium/gdpr-consent?style=social)](https://github.com/dorsium/gdpr-consent)

> Lightweight GDPR & Cookie Consent module for Next.js projects. Built by the Dorsium Foundation.

## Features

- GDPR-compliant cookie consent banner
- Categorized: Necessary, Analytics, Marketing
- Remembers preferences via `localStorage`
- Fully reusable NPM module
- `useConsent()` hook for conditional logic
- Styled with Tailwind CSS
- Powered by Dorsium branding included

## Installation

```bash
npm install @dorsium/gdpr
```

## Usage

### 1. Add the CookieConsent component (e.g. to `_app.tsx` or layout)
```tsx
import { CookieConsent } from "@dorsium/gdpr";

export default function App({ Component, pageProps }) {
return (
<>


>
);
}
```

### 2. Use the `useConsent()` hook to check preferences
```tsx
import { useConsent } from "@dorsium/gdpr";

export default function AnalyticsLoader() {
const { hasConsent } = useConsent();

useEffect(() => {
if (hasConsent("analytics")) {
// Load Google Analytics or other trackers here
}
}, [hasConsent]);

return null;
}
```

### 3. Optional: Show the Dorsium badge
```tsx
import { PoweredByDorsiumBadge } from "@dorsium/gdpr";

export default function Footer() {
return (



);
}
```

## Configuration
No configuration needed. Automatically saves user choices under `localStorage['dorsium_consent']`.

Only two boolean values are stored:
- `analytics`
- `marketing`

These flags are kept indefinitely in `localStorage` until you clear them. No personal data is stored.

## Build

```bash
npm run build
```

## License
This project is licensed under the [MIT License](LICENSE).

---

© Dorsium — https://dorsium.com

---

[![Powered by Dorsium](https://img.shields.io/badge/Powered%20by-Dorsium-3C6DF0?style=flat-square)](https://dorsium.com)

🔗 [View on NPM](https://www.npmjs.com/package/@dorsium/gdpr)
🔗 [Source on GitHub](https://github.com/dorsium/gdpr-consent)