3-line integration
Install via npm or load from CDN, initialize with a
single call, and CookieLaw handles banners, categories, and
consent storage for you.
CookieLaw is a lightweight JavaScript plugin that handles GDPR, ePrivacy, and CCPA cookie banners, preference storage, and audit logs – with 3 lines of code.
No bloated widgets, no trackers. CookieLaw is a small, audited plugin you can drop into any stack – static sites, SPA, or SSR.
Install via npm or load from CDN, initialize with a
single call, and CookieLaw handles banners, categories, and
consent storage for you.
Region-aware consent flows, granular opt-in, and audit-ready logs for your DPO and legal team. We ship templates vetted by privacy consultants.
Less than 3KB gzipped, zero dependencies, and no layout shift. Bundle it or lazy-load – your Lighthouse score stays green.
Understand which regions and categories get the highest acceptance rates and tune your copy with real data.
Use hooks and callbacks to block scripts, refresh tags, or sync consent status with your CMP or tag manager.
Keep everything on your own domain, or use our managed consent endpoints with SLA and regional routing.
Install the plugin, initialize it with your categories, and you have a fully functional cookie banner and preference center.
// 1) Install
npm install cookielaw
// 2) Import & initialize once in your app entry
import createCookieLaw from 'cookielaw';
const consent = createCookieLaw({
categories: {
necessary: { required: true },
analytics: { required: false, label: 'Analytics' },
marketing: { required: false }
},
regionHint: 'auto', // EU, US, global, or auto-detected
onDecision(value) {
// Example: only load analytics if consent.analytics === true
if (value.analytics) {
loadAnalyticsScript();
}
}
});
// 3) Show banner
consent.showBanner();
Prefer HTML? Drop our CDN script and call the same API:
window.CookieLaw with the same API.Need a custom design? Override our minimal CSS, or completely replace the markup while keeping the underlying consent logic.
Self-host the core library for free forever, or use the managed consent API for enterprise logging and SLAs.
Includes the full JavaScript library, hosted consent logs, and priority support.
If you don’t see your question here, reach out – we’re happy to review your specific use case.
Drop CookieLaw into your app, customize the banner, and ship compliant consent flows today – without another meeting.
Want a quick review from our team? Email hello@cookielaw.dev with your stack and traffic profile.