Introduction
astro-cookie-consent is a small Astro component plus a handful of plain JS functions for:
- Showing a cookie consent banner (single accept/decline, or per-category toggles).
- Actually blocking third-party scripts until the visitor accepts —
gateScript()never injects a<script>tag until consent is given. - Reading and reacting to the visitor’s choice anywhere else on the site.
It has no runtime dependencies, ships as plain .astro/.js source (compiled by your own
project’s Astro pipeline), and adds nothing to your node_modules beyond itself.
What it isn’t
Section titled “What it isn’t”- Not a full consent management platform. There’s no built-in geo-detection, no consent string (TCF/GPP) support, no vendor list. If you need IAB-standard consent signaling for ad exchanges, you likely need a dedicated CMP.
- Not legal advice. It’s a mechanism — you’re still responsible for what your privacy policy says, which categories you declare, and gating the right things behind the right category. See GDPR-related features for what the package does and doesn’t help with.
Where to go next
Section titled “Where to go next”- Installation & Quick Start — get a banner on screen in a couple of minutes.
- Live Demo — try the actual component, categories and all.
- Per-category consent — analytics/marketing-style toggles.
<ConsentBanner />reference — every prop.