Skip to main content

Documentation

Examples

Run an example from the c15t repository

The examples live in the examples directory of the c15t repository. They build against the packages in the repository, not against npm, so you clone the repository and build the packages first:

git clone --branch v3 https://github.com/c15t/c15t.git
cd c15t
bun install
bun run build:libs

You need Bun. Then run any example by its directory:

bun run --cwd examples/nextjs dev

Each example has a README that names the two or three files worth reading and how to point it at your backend. To add c15t to your own app, follow your framework quickstart instead; its setup code comes from the starters below.

Starters

A starter is the smallest correct setup for one framework and one rendering mode. Each one connects to Inth, shows the stock banner and dialog, keeps a Privacy settings control on the page after the banner closes, and loads PostHog only after the visitor allows measurement.

FrameworkDirectoryWhat it shows
Next.jsexamples/nextjsApp Router with a server-prefetched manifest
Next.jsexamples/nextjs-pages-routerPages Router with getServerSideProps
TanStack Startexamples/tanstack-startRequest middleware, a server function and the root route
Reactexamples/reactA Vite single-page app
Nuxtexamples/nuxtThe Nuxt module with the policy bundled at build time and resolved on the server
Nuxtexamples/nuxt-staticnuxt generate with the manifest resolved in the browser
Vueexamples/vueThe Vue plugin in a Vite single-page app
Astroexamples/astroServer output with the Node adapter
Astroexamples/astro-staticStatic output with every page prerendered
Svelteexamples/svelte@c15t/svelte in a Vite single-page app
SvelteKitexamples/sveltekitServer hooks and server-rendered layouts
HTMLexamples/htmlThe script tag on plain HTML pages
JavaScriptexamples/javascript@c15t/browser with a bundler

Replace https://your-project.inth.app with the backend URL from your Inth project, including any path prefix, and add the example's origin to the project's trusted origins. Server-rendered starters also read the URL from the framework's public environment variable; the README names it. Starters that download the policy when they build commit a .env that sets that variable to the https://example-inth.inth.app demo project, so they build on a fresh clone. Set your own URL in .env.local, which overrides it. Replace the placeholder PostHog key with your own, or remove the script.

examples/self-host is a Next.js App Router app with @c15t/backend mounted at /api/c15t in the same app. It runs on an embedded PGlite database in development and Postgres from DATABASE_URL when deployed. The backend quickstart publishes its route handler.

Showcases

Showcases are apps for Northwind Coffee, a made-up coffee roaster. Each one shows one thing c15t can do inside a believable product. All but one are Next.js apps.

ShowcaseDirectoryWhat it shows
Custom bannerexamples/showcase-custom-bannerA banner and preferences sheet built on the headless hooks, with no c15t stylesheet
Preference centerexamples/showcase-preference-centerConsent settings as a page in account settings, with categories, vendors and the last saved time
Gated embedsexamples/showcase-gated-embedsYouTube, Google Maps and a support chat behind designed placeholders that load in place
Analyticsexamples/showcase-analyticsGoogle Tag Manager with Consent Mode v2, GA4, PostHog and the Meta Pixel, with DevTools showing each script's state
IAB TCFexamples/showcase-iabA publisher's ad slots filled from the TC string, with GPP
Banner experimentexamples/showcase-experimentAn A/B test between two banner layouts, with exposure and choice events per arm
Multilingualexamples/showcase-multilingualBanner language from the route and policy from the visitor's region
Nuxt themeexamples/showcase-nuxt-themeThe stock Nuxt banner and dialog in a brand's colors, layout and dark mode, styled through module options

The Next.js showcases run in offline mode, so they work without an Inth project. Offline mode keeps choices in the browser and records nothing on a server. Not recommended for production environments. Each README shows the one-line swap to hosted({ backendURL: 'https://your-project.inth.app' }). The Nuxt module has no offline mode, so the Nuxt showcase talks to a demo Inth project and reads NUXT_PUBLIC_C15T_BACKEND_URL for your own.

The IAB showcase serves a three-vendor list from public/vendor-list.json and uses a demonstration CMP ID. Its README lists what changes for production.

What to try

Replace the placeholder PostHog key in examples/showcase-analytics/lib/scripts.ts with your own. Open the analytics showcase in a private window with DevTools Network open:

  1. Before you choose, no PostHog request appears.
  2. Reject optional categories and reload. The banner stays closed and PostHog stays absent.
  3. Open Privacy settings and allow Analytics (the measurement category). PostHog loads.
  4. Withdraw it again. The page reloads without PostHog. Reloading cannot undo code that already ran, which is why c15t reloads by default.

Tests

CI smoke-tests selected starters and checks that the banner renders, that Accept persists across a reload and that Privacy settings opens the dialog:

bunx playwright@1.61.1 install chromium
STARTER_TARGET=nextjs bun run --cwd internals/fixtures/acceptance test:starters

The full consent journeys run against separate test apps in internals/fixtures, which carry the test hooks the examples leave out:

EXAMPLE_TARGET=nextjs bun run --cwd internals/fixtures/acceptance test

Both variables take a comma-separated list of targets, such as react,tanstack-start, or all. See the verification guide for the checks to run against your own backend and vendor accounts before you ship.