Deploy a custom cookie banner, manage script blocking and record user consent across every XMS Ai project — without writing a single line of code.
$ npm install @xms-ai/real-cookies
Live Demo
Test the Real Cookies banner in different modes. Each button resets stored consent and launches a fresh banner.
Detects your country via IP and shows the correct compliance banner.
Full GDPR banner with Reject All, granular toggles, and compliance badge.
LGPD-compliant controls for Brazilian users.
Dark-themed popup positioned at the center-bottom of the screen.
Orange brand color, top position, with a custom company name.
Why Real Cookies
A minimal, production-ready cookie consent solution that works in any JavaScript project without a build step.
IP geolocation automatically selects the correct compliance mode — GDPR for EU, LGPD for Brazil, PIPEDA for Canada, or a basic notice everywhere else.
Toggle Necessary, Functional, Analytics, and Marketing cookies individually. Users can customize their exact preferences.
Pure vanilla JavaScript. No jQuery, React, or heavy frameworks. The minified bundle is under 30 KB.
Works perfectly without any backend. Consent is stored locally and syncs to Supabase when configured.
Automatically calls gtag('consent', 'update', …) when the user makes a choice, compatible with
Google's consent framework.
ARIA roles, keyboard navigation, focus-visible ring styles, and semantic HTML throughout the banner.
Setup
No build pipeline required. Works as an ES module, a script tag, or an npm package.
Add the package via npm or include the CDN script tag before your closing </body>.
Call CookieConsent.init() with your brand color and privacy policy URL.
Real Cookies auto-detects the user's country and shows the right consent UI. Preferences are stored instantly.
Listen for the vc:consent window event or call hasConsent('analytics') before
loading tracking scripts.
Documentation
Copy-paste ready snippets for the most common setups.
// 1. Install // npm install @xms-ai/real-cookies import CookieConsent from '@xms-ai/real-cookies'; await CookieConsent.init({ companyName: 'Acme Corp', primaryColor: '#1863dc', privacyUrl: '/privacy', }); // React to user decision window.addEventListener('vc:consent', (e) => { if (e.detail.categories.analytics) loadGoogleAnalytics(); });
<!-- Add before </body> --> <script src="https://cdn.jsdelivr.net/npm/@xms-ai/real-cookies/dist/cookie-consent.min.js"></script> <script> CookieConsent.init({ companyName: 'Acme Corp', primaryColor: '#1863dc', privacyUrl: '/privacy', }); </script>
CookieConsent.init({ // Branding companyName: 'Acme Corp', // shown in the banner companyLogo: '/logo.svg', // replaces cookie icon primaryColor: '#1863dc', // buttons, toggles, accent bar theme: 'light', // 'light' | 'dark' position: 'bottom', // 'bottom' | 'top' | 'popup' // Legal privacyUrl: '/privacy', cookiePolicyUrl: '/cookies', // Behaviour autoShow: true, cookieExpiry: 365, // days forceMode: null, // 'GDPR' | 'UK_GDPR' | 'LGPD' | 'PIPEDA' | 'BASIC' });
| Method / Event | Returns | Description |
|---|---|---|
CookieConsent.init(options) |
Promise |
Initialize the plugin. Must be called once. |
CookieConsent.hasConsent('analytics') |
boolean |
Check if the user consented to a specific category. |
CookieConsent.getConsent() |
object | null |
Returns the full consent record or null if none. |
CookieConsent.openSettings() |
void |
Programmatically open the preferences panel. |
CookieConsent.resetConsent() |
void |
Clear stored consent and show the banner again. |
window event: 'vc:consent' |
— | Fired after any consent action. event.detail = full record. |
window event: 'vc:consent:analytics' |
— | Per-category events. Replace analytics with any key. |
Drop one line into any project and you're compliant — GDPR, LGPD, PIPEDA, automatically.
npm install @xms-ai/real-cookies