Cookie banner for Svelte / SvelteKit
Comply with GDPR and Google Consent Mode v2 on your Svelte / SvelteKit site with a banner that really blocks scripts before consent and won't slow your site down.
SvelteKit combines server rendering and prerendering, which makes a poorly integrated CMP fail differently than a normal SPA: if the banner depends on document.cookie during build or SSR, it breaks. The fix is to render a neutral state server-side and check real consent only after hydration, with the snippet loaded from app.html, not from a component that hydrates late.
How to install it on Svelte / SvelteKit
- 1. Create your free account (Free plan, 1 site) at signup — no card required. Start free →
- 2. Open the dashboard, create your site and copy the snippet with your siteKey.
- 3. Paste the snippet in src/app.html inside <head>, before any analytics or GTM script added in +layout.svelte.
- 4. Open the site in incognito, reject cookies and check in DevTools that there are no _ga / pixels before accept.
- 5. Done! The banner appears and Consent Mode v2 is active automatically. Need more sites or logs? Upgrade to Pro (€9/mo).
Using Google Tag Manager?
Import our official template and fire it with the "Consent Initialization" trigger.
⬇ Download GTM templateCommon mistakes with cookies on Svelte / SvelteKit
- ⚠️ Reading document.cookie outside a typeof window !== 'undefined' guard breaks prerendering.
- ⚠️ Banner as a regular Svelte component instead of a snippet in app.html: it hydrates late and lets tags through first.
- ⚠️ Build-time prerendered routes that never see the real visitor's consent decision.
Why Consentio and not just any free plugin
- ✅ Real script blocking (most plugins don't do this).
- ✅ Full Google Consent Mode v2, with all 4 signals.
- ✅ Under 9 KB: it won't hurt your speed or your rankings.
- ✅ 6 languages and automatic visitor-country detection, included in every plan.
- ✅ Cookie scanner and automatic declaration ready for your policy.
- ✅ Auto-blocking of known trackers and consent records as proof in case of an audit.
Guides for other platforms
- Cookie banner for Laravel
- Cookie banner for Elementor
- Cookie banner for Google Sites
- Cookie banner for Nuxt
- Cookie banner for Hostinger
- Cookie banner for Carrd