Minimal Setup
You can have a working consent banner on any website in under 5 minutes. No backend, no database, no build tool required if you prefer CDN. This guide walks you through the fastest path to a live banner and explains what each step does.
Step 1 — Install the package
Choose the installation method that fits your project. All three produce the same widget — the only difference is how it gets to the browser.
npm install @consenti/uiConsentiSetup injects its own <style> tag on first render. If you already have a design system and want full control over the look, set core.disableCssTemplate: true to skip all style injection and style from scratch using BEM class names.Step 2 — Instantiate the widget
Import ConsentiSetupand call it with a compliance type. The simplest possible setup auto-detects the visitor's region from their browser timezone and language, then shows the right banner automatically.
import { ConsentiSetup } from '@consenti/ui'
// Auto-detects region from browser timezone + language
const widget = new ConsentiSetup({})
// Or pin a specific regulation — GDPR for all visitors
const widget = new ConsentiSetup({ compliance: { type: 'opt-in' } })On first visit, a banner appears at the bottom of the screen. The visitor accepts, rejects, or customises. On every subsequent visit, Consenti reads the stored cookie and the banner stays hidden.
What just happened?
When you call new ConsentiSetup(), the widget:
- Checks whether a consent cookie already exists for this visitor.
- If no cookie exists, determines which compliance profile to load (geo-resolved or fixed).
- Downloads only the relevant profile chunk — typically a few KB.
- Injects the banner DOM into the page.
- Waits for the visitor to interact, then writes the consent cookie.
new ConsentiSetup() during server-side rendering is a silent no-op — it never touches the DOM. You never need to guard the import.Next steps
Now that the banner is live, you probably want to react to consent decisions in your own code:
widget.on('consentSubmitted', (data) => {
if (data.consent.analytics === 'granted') {
initAnalytics()
}
})For a full picture of the consent lifecycle — from first visit to cookie expiry — read How Consent Flow Works.