@c15t/astro: Astro cookie banner and cookie consent management
Cookie banner, preference dialog, and consent-gated scripts for Astro 5, 6, and 7. Middleware resolves each request's consent policy, such as GDPR opt-in in the EU. The banner is plain .astro markup with no framework JavaScript. The preference dialog loads as a Svelte, React, or Vue island only when a visitor opens it.
c15t is used by 2,100+ sites, including expo.dev, zed.dev, unkey.dev, mintlify.com, and sazabi.com.
Key Features
- Visitors download no UI framework for the banner. The dialog's framework loads only when a visitor opens it
- Write the dialog island in Svelte, React, or Vue, so it uses the framework your site already ships
- Static output works on any static host with
hosted(). Server output resolves each visitor's policy, so the banner is in the first HTML - Geo-aware middleware reads location and language headers from your host
- Analytics, ads, and pixels follow each visitor's choice through @c15t/integrations: Google Tag Manager, Google Consent Mode v2, GA4, Meta Pixel, PostHog, and more
- IAB TCF 2.4 banner and dialog components
Prerequisites
- Astro 5, 6, or 7
- One of
@astrojs/svelte,@astrojs/react, or@astrojs/vuefor the preference dialog - A server adapter for server output, or none for static output
- An Inth project (free sign-up). For development and tests, local mode needs no backend
Installation
pnpm add c15t @astrojs/svelte svelte @astrojs/node
The c15t package re-exports this package at c15t/astro, and the docs use that path. For React or Vue dialogs, install @astrojs/react react react-dom or @astrojs/vue vue instead of Svelte. @astrojs/node is the server adapter in the example below. Use your host's adapter instead, or leave it out for static output.
Usage
- Set
PUBLIC_C15T_BACKEND_URLto your Inth backend URL in.env - Register your UI framework, then
c15t(), inastro.config.mjs
// astro.config.mjs
import node from '@astrojs/node'
import svelte from '@astrojs/svelte'
import { defineConfig } from 'astro/config'
import c15t from 'c15t/astro'
export default defineConfig({
adapter: node({ mode: 'standalone' }),
integrations: [svelte(), c15t()],
output: 'server',
})
- Add
ConsentScriptto<head>, andConsentBanner,ConsentDialog, andConsentDialogLinkto your layout, fromc15t/astro/components - For static output, the full layout, and island options, see the Astro quickstart
Run c15t on Inth
c15t needs a backend to serve policies and keep consent records. Inth runs it for you. It stores every choice with its region and policy version, audits your live site and pull requests for privacy risk, and on Pro and above keeps each region's consent rules current with managed policy packs. You don't run the consent database, geo lookups, uptime, or upgrades.
Sign-up is free. Run npx @inth/cli c15t to create a project and set up c15t, or create one by hand and copy its backend URL.
For development and tests, local mode keeps choices in the browser and keeps no consent records. Don't ship it to production. Its factory is local(). The old name, offline(), still works and goes away in v4.
Documentation
See the documentation for guides, API reference, and examples.
Docs for AI Agents
This package ships its documentation as Markdown, matched to the installed version. After you install it, point your coding agent at node_modules/@c15t/astro/AGENTS.md. It indexes every guide in node_modules/@c15t/astro/docs/.
On the web, every page of the c15t docs has a Markdown version, and llms.txt lists them all. Install the c15t agent skills with npx skills add c15t/skills.
Support
- Join our Discord community
- Open an issue on our GitHub repository
- Visit inth.com and use the chat widget
- Contact our support team via email [email protected]
Contributing
- Read the contribution guidelines before you open a pull request
- Follow the code of conduct
Security
Do not open a public issue for a security vulnerability. Report it privately through GitHub's vulnerability reporting. We examine every valid report.
- Do not share the vulnerability in public forums, issues, or pull requests
- Give the steps to reproduce it and the versions it affects
- Give us time to release a fix before you disclose it
License
Built by Inth