Guides

Cookie consent

Configure the cookie banner and the preferences centre, and load scripts only with consent.

composables/landing-page/useCookieConsent.ts

The landing pages include a cookie banner with a preferences centre. Everything is decided in the content of each landing (content/<landing>/<code>.ts, key cookies), so you never edit a component.

Piece
File
Purpose
LandingCookieBannercomponents/landing/LandingCookieBanner.vueFirst-visit banner and an optional button to reopen it.
LandingCookiePreferencescomponents/landing/LandingCookiePreferences.vueDialog with categories, switches and the cookie table.
useCookieConsent()composables/landing-page/useCookieConsent.tsReads the consent and opens the preferences from anywhere.
Not legal advice
Check with whoever handles legal matters which law applies to your site, which texts you need and which cookies you really use.

1. Do you need a banner?

  • No cookies, or only technical ones without a notice: remove cookies from the content. Nothing renders and the footer hides “Cookie settings”.
  • Only necessary cookies, but you want to inform: mode: 'notice', a banner with a single “Got it” button.
  • Optional cookies (analytics, marketing…): mode: 'opt-in' or 'opt-out' depending on the law.

2. Pick the mode

mode
Before the visitor decides
Banner buttons
Typical laws
opt-in (default)Optional cookies **off**Reject all, Accept all, CustomiseGDPR + ePrivacy (EU, EEA), UK GDPR, LGPD (Brazil), nFADP (Switzerland)
opt-outOptional cookies **on**Reject all, Accept all, CustomiseCCPA/CPRA (California) and similar US state laws
noticeOnly necessary cookiesGot itSites without optional cookies

If your audience is in several regions, use the strictest mode (opt-in). In the first two modes “Reject all” and “Accept all” have the same visual weight, as European authorities (EDPB, CNIL, AEPD) require.

3. Configure it

content/template/en.ts
cookies: {
  mode: 'opt-in',
  version: '2026-10',
  expiresInDays: 180,
  reopenButton: false,
  title: 'Your privacy, your choice',
  policy: { label: 'Cookie policy', to: '/legal/cookies' },
  categories: [
    {
      id: 'necessary',
      required: true,
      cookies: [{ name: 'landing-consent', provider: 'This site', duration: '6 months', purpose: 'Stores your choice' }],
    },
    { id: 'analytics', cookies: [{ name: '_ga', provider: 'Google Analytics', duration: '2 years', purpose: 'Measures visits' }] },
    { id: 'chat', title: 'Support chat', description: 'Keeps the conversation open between pages.' },
  ],
},
Field
Default
Notes
modeopt-inSee the table above.
version1Change it when you add cookies or change the policy: the banner shows again to everyone.
expiresInDays180How often to ask again. CNIL recommends at most 13 months (about 395 days).
reopenButtonfalseA floating button to reopen. The footer link is always there.
title, textTexts from locales/<code>/landing.jsontext has its own default for notice.
policy—A LandingAction, shown in the banner and in the preferences.
categoriesnecessary, analytics, marketingnecessary, preferences, analytics and marketing have translated titles; any other id needs a title.

A category with required: true shows as “Always on”. If every category is required there is no preferences screen. cookies inside a category is optional; without it the category does not expand.

The banner does not block scripts by itself: you decide what loads.

ts
const { hasConsent } = useCookieConsent()

watch(
  () => hasConsent('analytics'),
  (allowed) => {
    if (allowed) loadAnalytics()
  },
  { immediate: true }
)
Returns
Meaning
hasConsent(id)true if the category is required, accepted, or if the mode is opt-out and the visitor has not decided yet.
hasDecidedThe visitor chose with the current version.
consent{ version, categories, updatedAt } as stored, read only.
openPreferences()Opens the preferences dialog. The footer link uses it.
canCustomizeThere are optional categories the visitor can change.

The choice is stored in the landing-consent cookie, not in localStorage, so server and browser render the same thing. updatedAt records when consent was given; if your law requires storing it on a server, send it from a watch on consent.

Checklist before publishing

  • A real list of cookies per category (name, provider, duration, purpose).
  • policy points to a cookie policy page that exists.
  • No optional script loads without hasConsent().
  • version updated if you changed cookies or the policy.
© 2026 melsami UI.
Developer documentation for melsami UI.