Astro plugin
Cookie Consent for Astro
A privacy-first cookie consent solution for Astro — fully customisable, zero default styling, and complete control over when analytics and marketing scripts run.
Modern privacy regulations require explicit user consent before loading analytics, marketing scripts, or setting non-essential cookies.
This plugin provides a clean, developer-controlled consent flow without dashboards, third-party services, or opinionated design. You control the visuals, behaviour, and integrations.
What this plugin does
- Displays a cookie consent banner with an optional preferences modal
- Prevents analytics and marketing scripts from loading before consent
- Exposes a simple JavaScript consent API
- Provides full CSS control with no enforced design
- Stores consent locally with automatic expiry
Installation
Installation happens in two simple steps. The plugin includes a small installer that configures everything automatically.
npm install astro-consent
npx astro-consent
- Adds the consent integration to
astro.config - Creates a fully editable
src/cookiebanner.cssfile - Ensures no non-essential scripts run before consent
The generated CSS file is never overwritten, giving you full control over layout, spacing, and visual design.
Project links
Source code, releases, documentation, and contribution guidelines.
Learn more about cookie consent
Understand how consent is stored, how the API works, and how to safely integrate analytics and marketing scripts.