Astro
Components
Where the components go
Every component reads Astro.locals.c15t, which the integration's middleware
sets on each request. Put them in the layout that wraps every page:
The c15t() integration in astro.config.mjs plays the part a provider plays
in React or Vue. It holds the configuration every component reads. See
Integration options.
Component reference
Import the components by name from c15t/astro/components. Astro compiles
the .astro files it re-exports, so a page ships only what it renders.
ConsentBannerDeferred is the exception: it renders a server island, which
Astro refuses to build on a site without an adapter, so import it from its
own path.
| Component | Import from | Renders |
|---|---|---|
ConsentScript | c15t/astro/components | Inline scripts for the boot payload and color scheme, and the theme <style> |
ConsentBanner | c15t/astro/components | The banner, as server HTML |
ConsentBannerDeferred | c15t/astro/components/consent-banner-deferred.astro | The banner, in a server island |
ConsentDialog | c15t/astro/components | An empty host for the preference dialog island |
ConsentDialogLink | c15t/astro/components | A button or link that opens a dialog |
IABConsentBanner | c15t/astro/components | The IAB TCF banner, as server HTML |
IABConsentDialog | c15t/astro/components | An empty host for the IAB TCF dialog island |
How much JavaScript each component ships
The banners and the link are plain .astro markup and ship no framework
JavaScript. One small shared script turns their buttons into consent actions.
The dialogs are islands in the framework the integration's ui option names,
and they download only when a visitor first reaches for one. See
Dialog islands and your own islands.
Astro has no floating preferences widget, consent gate component or dev tools component. Gate embeds with the pattern in Embeds, and inspect consent with the client API and DevTools.
What every component needs
- The
c15t()integration inastro.config.mjs, with its middleware on.ConsentBannerandIABConsentBannerthrow whenAstro.locals.c15tis missing, and the others render nothing useful without it. - A route that the middleware does not skip. A route in
middleware.skiphas noAstro.locals.c15t. - For the dialogs, the Astro integration of the
uiframework, listed beforec15t().