@c15t/svelte 3.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (274) hide show
  1. package/AGENTS.md +88 -0
  2. package/README.md +136 -0
  3. package/SKILL.md +14 -0
  4. package/dist/actions/focus-trap.d.ts +8 -0
  5. package/dist/actions/focus-trap.js +23 -0
  6. package/dist/actions/portal.d.ts +8 -0
  7. package/dist/actions/portal.js +39 -0
  8. package/dist/actions/scroll-lock.d.ts +8 -0
  9. package/dist/actions/scroll-lock.js +23 -0
  10. package/dist/components/action-button.svelte +119 -0
  11. package/dist/components/action-button.svelte.d.ts +18 -0
  12. package/dist/components/branding.svelte +139 -0
  13. package/dist/components/branding.svelte.d.ts +13 -0
  14. package/dist/components/consent-dev-tools.svelte +58 -0
  15. package/dist/components/consent-dev-tools.svelte.d.ts +4 -0
  16. package/dist/components/frame.svelte +95 -0
  17. package/dist/components/frame.svelte.d.ts +12 -0
  18. package/dist/components/iab-panel.svelte +542 -0
  19. package/dist/components/iab-panel.svelte.d.ts +16 -0
  20. package/dist/components/iab-prompt.svelte +304 -0
  21. package/dist/components/iab-prompt.svelte.d.ts +14 -0
  22. package/dist/components/iab-purpose-item.svelte +511 -0
  23. package/dist/components/iab-purpose-item.svelte.d.ts +26 -0
  24. package/dist/components/iab-stack-item.svelte +146 -0
  25. package/dist/components/iab-stack-item.svelte.d.ts +19 -0
  26. package/dist/components/iab-vendor-list.svelte +900 -0
  27. package/dist/components/iab-vendor-list.svelte.d.ts +19 -0
  28. package/dist/components/icons/c15-t-icon-only.svelte +27 -0
  29. package/dist/components/icons/c15-t-icon-only.svelte.d.ts +9 -0
  30. package/dist/components/icons/chevron-down-icon.svelte +30 -0
  31. package/dist/components/icons/chevron-down-icon.svelte.d.ts +10 -0
  32. package/dist/components/icons/chevron-right-icon.svelte +36 -0
  33. package/dist/components/icons/chevron-right-icon.svelte.d.ts +12 -0
  34. package/dist/components/icons/close-icon.svelte +40 -0
  35. package/dist/components/icons/close-icon.svelte.d.ts +10 -0
  36. package/dist/components/icons/consent-icon-only.svelte +36 -0
  37. package/dist/components/icons/consent-icon-only.svelte.d.ts +9 -0
  38. package/dist/components/icons/external-link-icon.svelte +30 -0
  39. package/dist/components/icons/external-link-icon.svelte.d.ts +8 -0
  40. package/dist/components/icons/globe-icon.svelte +39 -0
  41. package/dist/components/icons/globe-icon.svelte.d.ts +9 -0
  42. package/dist/components/icons/info-icon.svelte +42 -0
  43. package/dist/components/icons/info-icon.svelte.d.ts +9 -0
  44. package/dist/components/icons/inth-logo.svelte +38 -0
  45. package/dist/components/icons/inth-logo.svelte.d.ts +9 -0
  46. package/dist/components/icons/layers-icon.svelte +25 -0
  47. package/dist/components/icons/layers-icon.svelte.d.ts +8 -0
  48. package/dist/components/icons/legitimate-interest-icon.svelte +29 -0
  49. package/dist/components/icons/legitimate-interest-icon.svelte.d.ts +10 -0
  50. package/dist/components/icons/lock-icon.svelte +31 -0
  51. package/dist/components/icons/lock-icon.svelte.d.ts +8 -0
  52. package/dist/components/icons/search-icon.svelte +33 -0
  53. package/dist/components/icons/search-icon.svelte.d.ts +8 -0
  54. package/dist/components/inline-legal-links.svelte +95 -0
  55. package/dist/components/inline-legal-links.svelte.d.ts +10 -0
  56. package/dist/components/manager-provider.svelte +459 -0
  57. package/dist/components/manager-provider.svelte.d.ts +27 -0
  58. package/dist/components/overlay.svelte +79 -0
  59. package/dist/components/overlay.svelte.d.ts +7 -0
  60. package/dist/components/panel-link.svelte +33 -0
  61. package/dist/components/panel-link.svelte.d.ts +10 -0
  62. package/dist/components/panel-trigger.svelte +237 -0
  63. package/dist/components/panel-trigger.svelte.d.ts +16 -0
  64. package/dist/components/panel.svelte +258 -0
  65. package/dist/components/panel.svelte.d.ts +22 -0
  66. package/dist/components/policy-actions-renderer.svelte +79 -0
  67. package/dist/components/policy-actions-renderer.svelte.d.ts +19 -0
  68. package/dist/components/preferences.svelte +320 -0
  69. package/dist/components/preferences.svelte.d.ts +8 -0
  70. package/dist/components/prompt.svelte +514 -0
  71. package/dist/components/prompt.svelte.d.ts +43 -0
  72. package/dist/context.svelte.d.ts +125 -0
  73. package/dist/context.svelte.js +354 -0
  74. package/dist/devtools-options.d.ts +7 -0
  75. package/dist/devtools-options.js +1 -0
  76. package/dist/devtools.d.ts +9 -0
  77. package/dist/devtools.js +7 -0
  78. package/dist/headless.d.ts +10 -0
  79. package/dist/headless.js +7 -0
  80. package/dist/iab/styles.css +11 -0
  81. package/dist/iab-loader.d.ts +30 -0
  82. package/dist/iab-loader.js +33 -0
  83. package/dist/iab-translations.d.ts +84 -0
  84. package/dist/iab-translations.js +45 -0
  85. package/dist/iab-types.d.ts +62 -0
  86. package/dist/iab-types.js +43 -0
  87. package/dist/index.d.ts +28 -0
  88. package/dist/index.js +21 -0
  89. package/dist/kit/app.d.ts +35 -0
  90. package/dist/kit/handle.d.ts +34 -0
  91. package/dist/kit/handle.js +87 -0
  92. package/dist/kit/index.d.ts +30 -0
  93. package/dist/kit/index.js +5 -0
  94. package/dist/kit/load-consent.d.ts +57 -0
  95. package/dist/kit/load-consent.js +144 -0
  96. package/dist/kit/routes.d.ts +46 -0
  97. package/dist/kit/routes.js +203 -0
  98. package/dist/kit/types.d.ts +56 -0
  99. package/dist/kit/types.js +1 -0
  100. package/dist/primitives/accordion/accordion-item-content.svelte +35 -0
  101. package/dist/primitives/accordion/accordion-item-content.svelte.d.ts +9 -0
  102. package/dist/primitives/accordion/accordion-item-trigger.svelte +54 -0
  103. package/dist/primitives/accordion/accordion-item-trigger.svelte.d.ts +10 -0
  104. package/dist/primitives/accordion/accordion-item.svelte +61 -0
  105. package/dist/primitives/accordion/accordion-item.svelte.d.ts +11 -0
  106. package/dist/primitives/accordion/accordion-root.svelte +61 -0
  107. package/dist/primitives/accordion/accordion-root.svelte.d.ts +13 -0
  108. package/dist/primitives/accordion/context.d.ts +18 -0
  109. package/dist/primitives/accordion/context.js +23 -0
  110. package/dist/primitives/accordion/index.d.ts +29 -0
  111. package/dist/primitives/accordion/index.js +11 -0
  112. package/dist/primitives/collapsible/collapsible-content.svelte +36 -0
  113. package/dist/primitives/collapsible/collapsible-content.svelte.d.ts +9 -0
  114. package/dist/primitives/collapsible/collapsible-indicator.svelte +29 -0
  115. package/dist/primitives/collapsible/collapsible-indicator.svelte.d.ts +9 -0
  116. package/dist/primitives/collapsible/collapsible-root.svelte +70 -0
  117. package/dist/primitives/collapsible/collapsible-root.svelte.d.ts +11 -0
  118. package/dist/primitives/collapsible/collapsible-trigger.svelte +52 -0
  119. package/dist/primitives/collapsible/collapsible-trigger.svelte.d.ts +10 -0
  120. package/dist/primitives/collapsible/context.d.ts +10 -0
  121. package/dist/primitives/collapsible/context.js +12 -0
  122. package/dist/primitives/collapsible/index.d.ts +26 -0
  123. package/dist/primitives/collapsible/index.js +11 -0
  124. package/dist/primitives/dialog/context.d.ts +14 -0
  125. package/dist/primitives/dialog/context.js +12 -0
  126. package/dist/primitives/dialog/dialog-backdrop.svelte +39 -0
  127. package/dist/primitives/dialog/dialog-backdrop.svelte.d.ts +7 -0
  128. package/dist/primitives/dialog/dialog-close-trigger.svelte +48 -0
  129. package/dist/primitives/dialog/dialog-close-trigger.svelte.d.ts +11 -0
  130. package/dist/primitives/dialog/dialog-content.svelte +81 -0
  131. package/dist/primitives/dialog/dialog-content.svelte.d.ts +9 -0
  132. package/dist/primitives/dialog/dialog-description.svelte +28 -0
  133. package/dist/primitives/dialog/dialog-description.svelte.d.ts +9 -0
  134. package/dist/primitives/dialog/dialog-positioner.svelte +33 -0
  135. package/dist/primitives/dialog/dialog-positioner.svelte.d.ts +9 -0
  136. package/dist/primitives/dialog/dialog-root.svelte +117 -0
  137. package/dist/primitives/dialog/dialog-root.svelte.d.ts +14 -0
  138. package/dist/primitives/dialog/dialog-title.svelte +28 -0
  139. package/dist/primitives/dialog/dialog-title.svelte.d.ts +9 -0
  140. package/dist/primitives/dialog/index.d.ts +50 -0
  141. package/dist/primitives/dialog/index.js +19 -0
  142. package/dist/primitives/index.d.ts +7 -0
  143. package/dist/primitives/index.js +7 -0
  144. package/dist/primitives/portal/index.d.ts +4 -0
  145. package/dist/primitives/portal/index.js +2 -0
  146. package/dist/primitives/portal/portal.svelte +23 -0
  147. package/dist/primitives/portal/portal.svelte.d.ts +9 -0
  148. package/dist/primitives/preference-item/context.d.ts +11 -0
  149. package/dist/primitives/preference-item/context.js +12 -0
  150. package/dist/primitives/preference-item/index.d.ts +54 -0
  151. package/dist/primitives/preference-item/index.js +21 -0
  152. package/dist/primitives/preference-item/preference-item-auxiliary.svelte +33 -0
  153. package/dist/primitives/preference-item/preference-item-auxiliary.svelte.d.ts +9 -0
  154. package/dist/primitives/preference-item/preference-item-content.svelte +68 -0
  155. package/dist/primitives/preference-item/preference-item-content.svelte.d.ts +14 -0
  156. package/dist/primitives/preference-item/preference-item-control.svelte +33 -0
  157. package/dist/primitives/preference-item/preference-item-control.svelte.d.ts +9 -0
  158. package/dist/primitives/preference-item/preference-item-header.svelte +33 -0
  159. package/dist/primitives/preference-item/preference-item-header.svelte.d.ts +9 -0
  160. package/dist/primitives/preference-item/preference-item-leading.svelte +33 -0
  161. package/dist/primitives/preference-item/preference-item-leading.svelte.d.ts +9 -0
  162. package/dist/primitives/preference-item/preference-item-meta.svelte +33 -0
  163. package/dist/primitives/preference-item/preference-item-meta.svelte.d.ts +9 -0
  164. package/dist/primitives/preference-item/preference-item-root.svelte +82 -0
  165. package/dist/primitives/preference-item/preference-item-root.svelte.d.ts +12 -0
  166. package/dist/primitives/preference-item/preference-item-title.svelte +33 -0
  167. package/dist/primitives/preference-item/preference-item-title.svelte.d.ts +9 -0
  168. package/dist/primitives/preference-item/preference-item-trigger.svelte +62 -0
  169. package/dist/primitives/preference-item/preference-item-trigger.svelte.d.ts +10 -0
  170. package/dist/primitives/switch/context.d.ts +7 -0
  171. package/dist/primitives/switch/context.js +12 -0
  172. package/dist/primitives/switch/index.d.ts +25 -0
  173. package/dist/primitives/switch/index.js +11 -0
  174. package/dist/primitives/switch/switch-control.svelte +21 -0
  175. package/dist/primitives/switch/switch-control.svelte.d.ts +9 -0
  176. package/dist/primitives/switch/switch-hidden-input.svelte +31 -0
  177. package/dist/primitives/switch/switch-hidden-input.svelte.d.ts +8 -0
  178. package/dist/primitives/switch/switch-root.svelte +86 -0
  179. package/dist/primitives/switch/switch-root.svelte.d.ts +12 -0
  180. package/dist/primitives/switch/switch-thumb.svelte +14 -0
  181. package/dist/primitives/switch/switch-thumb.svelte.d.ts +7 -0
  182. package/dist/primitives/tabs/context.d.ts +11 -0
  183. package/dist/primitives/tabs/context.js +12 -0
  184. package/dist/primitives/tabs/index.d.ts +32 -0
  185. package/dist/primitives/tabs/index.js +11 -0
  186. package/dist/primitives/tabs/tabs-content.svelte +45 -0
  187. package/dist/primitives/tabs/tabs-content.svelte.d.ts +11 -0
  188. package/dist/primitives/tabs/tabs-list.svelte +38 -0
  189. package/dist/primitives/tabs/tabs-list.svelte.d.ts +10 -0
  190. package/dist/primitives/tabs/tabs-root.svelte +67 -0
  191. package/dist/primitives/tabs/tabs-root.svelte.d.ts +14 -0
  192. package/dist/primitives/tabs/tabs-trigger.svelte +108 -0
  193. package/dist/primitives/tabs/tabs-trigger.svelte.d.ts +11 -0
  194. package/dist/server/headers.d.ts +13 -0
  195. package/dist/server/headers.js +37 -0
  196. package/dist/server/index.d.ts +8 -0
  197. package/dist/server/index.js +116 -0
  198. package/dist/server/normalize-url.d.ts +23 -0
  199. package/dist/server/normalize-url.js +46 -0
  200. package/dist/server/types.d.ts +25 -0
  201. package/dist/server/types.js +1 -0
  202. package/dist/styles.css +10 -0
  203. package/dist/transports/offline.d.ts +14 -0
  204. package/dist/transports/offline.js +22 -0
  205. package/dist/types.d.ts +70 -0
  206. package/dist/types.js +1 -0
  207. package/dist/use-banner-visibility.svelte.d.ts +25 -0
  208. package/dist/use-banner-visibility.svelte.js +108 -0
  209. package/dist/utils.d.ts +25 -0
  210. package/dist/utils.js +32 -0
  211. package/dist/version.d.ts +1 -0
  212. package/dist/version.js +2 -0
  213. package/docs/README.md +88 -0
  214. package/docs/assets/v3/brand-bar.png +0 -0
  215. package/docs/assets/v3/brand-card.png +0 -0
  216. package/docs/assets/v3/choice-wall.png +0 -0
  217. package/docs/assets/v3/mobile-card.png +0 -0
  218. package/docs/assets/v3/preferences.png +0 -0
  219. package/docs/customization/overview.md +45 -0
  220. package/docs/customization/recipes.md +79 -0
  221. package/docs/customization/slots.md +55 -0
  222. package/docs/customization/tokens.md +76 -0
  223. package/docs/customization/translations.md +49 -0
  224. package/docs/frameworks/svelte/quickstart.md +133 -0
  225. package/docs/frameworks/sveltekit/quickstart.md +144 -0
  226. package/docs/guides/consent-state.md +60 -0
  227. package/docs/guides/data-fetching.md +163 -0
  228. package/docs/guides/deployment-modes.md +63 -0
  229. package/docs/guides/troubleshooting.md +68 -0
  230. package/docs/guides/verify-consent.md +62 -0
  231. package/docs/integrations/adobe-analytics.md +294 -0
  232. package/docs/integrations/ahrefs-analytics.md +291 -0
  233. package/docs/integrations/amplitude.md +292 -0
  234. package/docs/integrations/building-integrations.md +47 -0
  235. package/docs/integrations/clearbit.md +291 -0
  236. package/docs/integrations/cloudflare-web-analytics.md +292 -0
  237. package/docs/integrations/crisp.md +294 -0
  238. package/docs/integrations/databuddy.md +311 -0
  239. package/docs/integrations/fathom-analytics.md +293 -0
  240. package/docs/integrations/google-maps.md +384 -0
  241. package/docs/integrations/google-tag-manager.md +306 -0
  242. package/docs/integrations/google-tag.md +305 -0
  243. package/docs/integrations/heap.md +292 -0
  244. package/docs/integrations/hightouch.md +293 -0
  245. package/docs/integrations/hotjar.md +292 -0
  246. package/docs/integrations/intercom.md +285 -0
  247. package/docs/integrations/linkedin-insights.md +291 -0
  248. package/docs/integrations/logrocket.md +293 -0
  249. package/docs/integrations/matomo-analytics.md +316 -0
  250. package/docs/integrations/meta-pixel.md +285 -0
  251. package/docs/integrations/microsoft-clarity.md +292 -0
  252. package/docs/integrations/microsoft-uet.md +291 -0
  253. package/docs/integrations/mixpanel-analytics.md +295 -0
  254. package/docs/integrations/openai-pixel.md +441 -0
  255. package/docs/integrations/overview.md +111 -0
  256. package/docs/integrations/pirsch.md +295 -0
  257. package/docs/integrations/plausible-analytics.md +295 -0
  258. package/docs/integrations/posthog.md +397 -0
  259. package/docs/integrations/promptwatch.md +291 -0
  260. package/docs/integrations/reddit-pixel.md +294 -0
  261. package/docs/integrations/rudderstack.md +328 -0
  262. package/docs/integrations/rybbit-analytics.md +296 -0
  263. package/docs/integrations/segment.md +292 -0
  264. package/docs/integrations/snapchat-pixel.md +293 -0
  265. package/docs/integrations/tiktok-pixel.md +291 -0
  266. package/docs/integrations/umami-analytics.md +295 -0
  267. package/docs/integrations/vercel-analytics.md +293 -0
  268. package/docs/integrations/x-pixel.md +291 -0
  269. package/docs/integrations/youtube.md +405 -0
  270. package/docs/upgrade-v3.md +334 -0
  271. package/iab/styles.css +1 -0
  272. package/package.json +153 -0
  273. package/readme.json +36 -0
  274. package/styles.css +1 -0
@@ -0,0 +1,133 @@
1
+ ---
2
+ title: Quickstart
3
+ description: Mount c15t components and a persistent preferences link in a Svelte
4
+ 5 application.
5
+ group: frameworks
6
+ ---
7
+
8
+ [Create an Inth project](https://inth.com) and use its backend endpoint in
9
+ this guide. Configure the project's policy rules and allowed app origins first.
10
+
11
+ ## Install
12
+
13
+ | Package manager | Command |
14
+ | :-------------- | :--------------------------------------- |
15
+ | npm | `npm install @c15t/svelte @c15t/scripts` |
16
+ | pnpm | `pnpm add @c15t/svelte @c15t/scripts` |
17
+ | yarn | `yarn add @c15t/svelte @c15t/scripts` |
18
+ | bun | `bun add @c15t/svelte @c15t/scripts` |
19
+
20
+ ## Register consent-gated scripts
21
+
22
+ Include measurement and marketing categories in your policy for these vendors.
23
+ Remove any existing loaders for them so each script loads once.
24
+
25
+ This setup uses Vite's public environment variables. Set the Inth endpoint and
26
+ add your PostHog project key, PostHog API host and X Pixel ID in `.env.local`:
27
+
28
+ ```dotenv title=".env.local"
29
+ VITE_C15T_BACKEND_URL=
30
+ VITE_POSTHOG_KEY=
31
+ VITE_POSTHOG_HOST=
32
+ VITE_X_PIXEL_ID=
33
+ ```
34
+
35
+ Copy the exact backend endpoint from Inth. The vendor IDs are optional: leaving
36
+ an ID empty disables that integration. When enabling PostHog, fill in both its project key and the API host
37
+ shown in your PostHog project. Restart Vite after editing these values and
38
+ rebuild for deployment. Other bundlers need their own configuration mechanism.
39
+
40
+ Create `src/scripts.ts`. PostHog waits for measurement permission with
41
+ `loadMode: 'after-consent'` and disables cookieless capture with
42
+ `cookieless_mode: 'never'`. X Pixel waits for marketing permission.
43
+
44
+ ```ts title="src/scripts.ts"
45
+ import { posthog } from '@c15t/scripts/posthog';
46
+ import { xPixel } from '@c15t/scripts/x-pixel';
47
+
48
+ const posthogKey = import.meta.env.VITE_POSTHOG_KEY;
49
+ const xPixelId = import.meta.env.VITE_X_PIXEL_ID;
50
+
51
+ export const scripts = [
52
+ ...(posthogKey
53
+ ? [
54
+ posthog({
55
+ apiHost: import.meta.env.VITE_POSTHOG_HOST,
56
+ id: posthogKey,
57
+ initOptions: { cookieless_mode: 'never' },
58
+ loadMode: 'after-consent',
59
+ }),
60
+ ]
61
+ : []),
62
+ ...(xPixelId ? [xPixel({ pixelId: xPixelId })] : []),
63
+ ];
64
+ ```
65
+
66
+ ## Mount the provider and UI
67
+
68
+ ```svelte title="src/App.svelte"
69
+ <script lang="ts">
70
+ import {
71
+ ConsentBanner,
72
+ ConsentDialog,
73
+ ConsentDialogLink,
74
+ ConsentManagerProvider,
75
+ hosted,
76
+ } from '@c15t/svelte';
77
+ import '@c15t/svelte/styles.css';
78
+ import { scripts } from './scripts';
79
+
80
+ const backendURL = import.meta.env.VITE_C15T_BACKEND_URL;
81
+ if (!backendURL) throw new Error('Set VITE_C15T_BACKEND_URL');
82
+ const mode = hosted({ url: backendURL });
83
+ </script>
84
+
85
+ <ConsentManagerProvider {mode} {scripts}>
86
+ <main>Your application</main>
87
+ <ConsentBanner />
88
+ <ConsentDialog />
89
+ <ConsentDialogLink>Privacy settings</ConsentDialogLink>
90
+ </ConsentManagerProvider>
91
+ ```
92
+
93
+ This example uses Svelte 5 and Vite. Set `VITE_C15T_BACKEND_URL` to your backend's
94
+ absolute URL. Configure the backend's policy rules and allowed app origin.
95
+ Svelte's provider is `ConsentManagerProvider` and accepts `mode` as a top-level
96
+ prop. Do not copy React's `ConsentProvider` name into a Svelte component.
97
+
98
+ The provider owns initialization and cleanup. Keep it mounted around the app
99
+ rather than creating a new provider for each page. The stylesheet supplies the
100
+ stock appearance. Use [customization](../../customization/overview.md) before
101
+ rebuilding the UI with headless APIs.
102
+
103
+ ## Use local policies when no backend is needed
104
+
105
+ Install `@c15t/schema` and replace the hosted mode in the example with this
106
+ configuration:
107
+
108
+ ```ts
109
+ import { offline } from '@c15t/svelte';
110
+ import { policyRulePresets } from '@c15t/schema';
111
+
112
+ const mode = offline({ policyRules: [policyRulePresets.europeOptIn()] });
113
+ ```
114
+
115
+ Not recommended for production environments.
116
+
117
+ This resolves policy locally and stores choices in the browser. It does not
118
+ provide a backend audit history. Review the preset's scope and fallback rather
119
+ than treating it as a complete compliance configuration.
120
+
121
+ ## Verify the lifecycle
122
+
123
+ Under a choice policy, reject optional categories and reload. Reopen preferences
124
+ and save a different choice. Check vendor requests using
125
+ [verification](../../guides/verify-consent.md). A missing banner can also mean the
126
+ resolved rule needs no prompt, so inspect policy resolution before changing CSS.
127
+
128
+ For request-specific initial HTML, use the SvelteKit server integration.
129
+
130
+ ## Run the complete example
131
+
132
+ Try the [runnable example](https://c15t.com/docs/examples) with PostHog, X Pixel, a consent-gated
133
+ YouTube video and a persistent preferences control. Use it to test rejection, permission changes and reloads.
@@ -0,0 +1,144 @@
1
+ ---
2
+ title: Quickstart
3
+ description: Resolve consent in a SvelteKit server load and hydrate the
4
+ provider, or initialize in the browser on static hosting.
5
+ group: frameworks
6
+ ---
7
+
8
+ [Create an Inth project](https://inth.com) and use its backend endpoint in
9
+ this guide. Configure the project's policy rules and allowed app origins first.
10
+
11
+ ## Install
12
+
13
+ | Package manager | Command |
14
+ | :-------------- | :--------------------------------------- |
15
+ | npm | `npm install @c15t/svelte @c15t/scripts` |
16
+ | pnpm | `pnpm add @c15t/svelte @c15t/scripts` |
17
+ | yarn | `yarn add @c15t/svelte @c15t/scripts` |
18
+ | bun | `bun add @c15t/svelte @c15t/scripts` |
19
+
20
+ Set `PUBLIC_C15T_BACKEND_URL` to an absolute consent backend URL. Configure
21
+ policy rules and the app origin on the backend. The URL is public because the
22
+ browser also uses it to save choices.
23
+
24
+ ## Register consent-gated scripts
25
+
26
+ Include measurement and marketing categories in your policy for these vendors.
27
+ Remove any existing loaders for them so each script loads once.
28
+
29
+ Add your PostHog project key and X Pixel ID to `.env`:
30
+
31
+ ```dotenv title=".env"
32
+ PUBLIC_POSTHOG_KEY=
33
+ PUBLIC_X_PIXEL_ID=
34
+ ```
35
+
36
+ The layout reads these public values through SvelteKit's `$env/dynamic/public`.
37
+ An empty ID disables that integration. Create `src/lib/example-scripts.ts`
38
+ using the helper below. It selects PostHog's EU region; change `region` to `'us'`
39
+ for a US project. PostHog waits for measurement permission and disables
40
+ cookieless capture. X Pixel waits for marketing permission.
41
+
42
+ ```ts title="src/lib/example-scripts.ts"
43
+ import { posthog } from '@c15t/scripts/posthog';
44
+ import { xPixel } from '@c15t/scripts/x-pixel';
45
+
46
+ export const createExampleScripts = (
47
+ posthogKey?: string,
48
+ xPixelId?: string
49
+ ) => [
50
+ ...(posthogKey
51
+ ? [
52
+ posthog({
53
+ id: posthogKey,
54
+ initOptions: { cookieless_mode: 'never' },
55
+ loadMode: 'after-consent',
56
+ region: 'eu',
57
+ }),
58
+ ]
59
+ : []),
60
+ ...(xPixelId ? [xPixel({ pixelId: xPixelId })] : []),
61
+ ];
62
+ ```
63
+
64
+ ## Resolve consent on each request
65
+
66
+ ```ts title="src/routes/+layout.server.ts"
67
+ import { env } from '$env/dynamic/public';
68
+ import { loadConsent } from '@c15t/svelte/kit';
69
+ import type { LayoutServerLoad } from './$types';
70
+
71
+ export const load: LayoutServerLoad = async (event) => {
72
+ const backendURL = env.PUBLIC_C15T_BACKEND_URL;
73
+ if (!backendURL) throw new Error('Set PUBLIC_C15T_BACKEND_URL');
74
+ return { prefetch: await loadConsent(event, { backendURL }), backendURL };
75
+ };
76
+ ```
77
+
78
+ ```svelte title="src/routes/+layout.svelte"
79
+ <script lang="ts">
80
+ import { env } from '$env/dynamic/public';
81
+ import { createExampleScripts } from '$lib/example-scripts';
82
+ import {
83
+ ConsentBanner,
84
+ ConsentDialog,
85
+ ConsentDialogLink,
86
+ ConsentManagerProvider,
87
+ hosted,
88
+ } from '@c15t/svelte';
89
+ import '@c15t/svelte/styles.css';
90
+
91
+ let { children, data } = $props();
92
+ const mode = hosted({ url: data.backendURL });
93
+ const scripts = createExampleScripts(env.PUBLIC_POSTHOG_KEY, env.PUBLIC_X_PIXEL_ID);
94
+ </script>
95
+
96
+ <ConsentManagerProvider {mode} prefetch={data.prefetch} {scripts}>
97
+ {@render children()}
98
+ <ConsentBanner />
99
+ <ConsentDialog />
100
+ <ConsentDialogLink>Privacy settings</ConsentDialogLink>
101
+ </ConsentManagerProvider>
102
+ ```
103
+
104
+ `loadConsent` reads the request and returns serializable prefetch data. Pass
105
+ that data through intact; reconstructing permissions as saved booleans loses
106
+ receipt and policy information. The provider's `mode` and `prefetch` are
107
+ top-level props.
108
+
109
+ For manifest-backed resolution, the package also exports
110
+ `createSvelteKitConsentRouteHandlers` from `@c15t/svelte/kit`. Once those routes
111
+ are mounted, `loadConsent(event, { initRoute: '/api/c15t' })` uses the app's own
112
+ init route through `event.fetch`. Merely changing the URL does not create it.
113
+
114
+ Past the manifest's `s-maxage` those routes serve it stale and refresh it in
115
+ the background. On adapters that expose `event.platform.context.waitUntil`
116
+ (Cloudflare, Vercel edge) the handlers hand the refresh to it so it is not cut
117
+ short when the response is sent; nothing is needed from you. For another
118
+ lifetime API, pass `onBackgroundRevalidate(refresh, event)` to the handlers.
119
+
120
+ ## Use static hosting
121
+
122
+ A prerendered page cannot resolve a visitor's cookies at build time. For static
123
+ output, omit the request-specific server load and `prefetch`. Configure
124
+ `hosted({ url })` in the layout with an absolute external backend URL, using a
125
+ public build-time value from `$env/static/public`. Read vendor IDs from
126
+ `$env/static/public` too for prerendering. Keep the provider and UI from
127
+ the example. Do not point at a same-origin server route that the static host
128
+ cannot run.
129
+
130
+ The browser initializes consent after mount. Optional permissions remain denied
131
+ while no policy has resolved. Follow your SvelteKit adapter's static deployment
132
+ configuration independently of consent setup.
133
+
134
+ ## Verify hydration and navigation
135
+
136
+ For SSR, a valid stored choice should survive the first client render without a
137
+ new choice event. For static output, serve the actual generated site. On both,
138
+ reject, navigate between routes, reload and reopen preferences. Check requests
139
+ and failed initialization with [verification](../../guides/verify-consent.md).
140
+
141
+ ## Run the complete example
142
+
143
+ Try the [runnable example](https://c15t.com/docs/examples) with PostHog, X Pixel, a consent-gated
144
+ YouTube video and a persistent preferences control. Use it to test rejection, permission changes and reloads.
@@ -0,0 +1,60 @@
1
+ ---
2
+ title: Understand consent state
3
+ description: Distinguish policy resolution, effective permissions, explicit
4
+ choices, notices and privacy signals.
5
+ group: guides
6
+ ---
7
+
8
+ ## Use effective permissions to gate features
9
+
10
+ `effectivePermissions` answers whether a category is allowed now. It combines
11
+ the resolved policy, stored choices and privacy signals. Under an opt-out rule,
12
+ permission can be true before the visitor acts. It is not evidence of a recorded
13
+ grant.
14
+
15
+ | Task | State or API |
16
+ | ------------------------------------------- | ---------------------------------------------------- |
17
+ | Load a script or render an optional feature | `effectivePermissions`, React `useConsent(category)` |
18
+ | Inspect what the visitor confirmed | `explicitChoice` |
19
+ | Decide whether to show a prompt | `promptRequirement` |
20
+ | Explain regional behavior | `policyRule` |
21
+ | Diagnose initialization | `resolution` |
22
+
23
+ ## Record only explicit visitor actions
24
+
25
+ ```ts
26
+ // Run in the corresponding click or form-submit handler.
27
+ await kernel.commands.save('all');
28
+ await kernel.commands.save('none');
29
+ await kernel.commands.save({ marketing: false });
30
+ ```
31
+
32
+ These are three separate examples: accept, reject and a partial save. A partial
33
+ save confirms only the supplied categories and keeps the other categories'
34
+ confirmation times. Do not call all three in one handler.
35
+
36
+ `onChoiceRecorded` reports an explicit choice. `onPermissionsChanged` reports
37
+ changes in effective permissions, including changes caused by expiry or privacy
38
+ signals. Hydration must not be counted as another visitor choice.
39
+
40
+ ## Treat notices and privacy signals separately
41
+
42
+ `commands.dismissNotice()` acknowledges the current notice. It does not grant
43
+ categories or overwrite existing denials. Global Privacy Control, or GPC, is a
44
+ browser privacy signal. Its configured restrictions can change permissions
45
+ without creating an explicit choice.
46
+
47
+ A rule with `prompt: 'none'` can still require a persistent preferences entry
48
+ point. Check the policy's rights instead of hiding preferences merely because
49
+ the banner is absent. An unresolved rule is another distinct state; optional
50
+ permissions stay denied until resolution succeeds.
51
+
52
+ ## Preserve records during hydration
53
+
54
+ Server helpers return records with policy information and evaluation time.
55
+ Forward that configuration intact. Copying an allowed category into a receipt
56
+ would invent a grant and lose its original confirmation time.
57
+
58
+ Valid v2 records can be read without a startup rewrite. The next explicit action
59
+ writes the v3 format. See [migration](../upgrade-v3.md) for expiry, partial saves,
60
+ custom transports and backend contract changes.
@@ -0,0 +1,163 @@
1
+ ---
2
+ title: Data fetching and transports
3
+ description: Choose cached manifests, backend init or offline policy resolution,
4
+ and understand where consent records are saved.
5
+ group: guides
6
+ ---
7
+
8
+ ## Start with Inth and a cached manifest
9
+
10
+ Use Inth for managed policy and consent records. For a Next.js application with
11
+ a server, use a cached manifest to resolve policy in your application. Route
12
+ browser consent traffic directly to Inth, or optionally use a Next.js rewrite
13
+ to keep those requests on your app's origin. Follow the
14
+ [Next.js manifest setup](https://c15t.com/docs/frameworks/next/data-fetching).
15
+
16
+ Backend ownership and data fetching are separate decisions. Inth manages the
17
+ backend for you. A [self-hosted backend](https://c15t.com/docs/self-host/quickstart) uses the same
18
+ protocol while you operate its database, policies and availability. A static
19
+ site can still call Inth. Only `offline()` deliberately removes consent backend
20
+ requests and stores choices locally.
21
+
22
+ | Fetching path | Where policy resolves | Where choices are submitted | Choose it when |
23
+ | ------------------------------ | ------------------------------------------------------------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------ |
24
+ | Cached manifest on your server | Your application resolves public policy data with each request's location and signals | Inth or your c15t backend | Your host has a runtime server and you want to reuse policy data across requests |
25
+ | Regular backend `/init` | The consent backend | The same backend | You want the fewest moving parts, need backend-owned request resolution, or have no application server |
26
+ | Manifest in the browser | The browser, using supplied or unknown location | Inth or your c15t backend | You deliberately want client resolution and have planned geography, bundle size and policy refresh |
27
+ | Offline | The browser or local runtime, using bundled rules | No backend submission | Local development and tests. Not recommended for production environments. |
28
+ | Custom transport | Your implementation | Your implementation | An existing service cannot use the c15t backend protocol |
29
+
30
+ ## What is a consent manifest?
31
+
32
+ A manifest is a versioned policy document served by `GET /manifest`. It contains
33
+ policy rules, translation configuration and related consent configuration. It
34
+ is public configuration, not a visitor's saved choices. A resolver combines the
35
+ manifest with country, region, language and privacy signals to produce an init
36
+ result for one visitor.
37
+
38
+ Reusing the public document avoids asking the consent backend to resolve policy
39
+ for every application request. Cache misses and revalidation still fetch the
40
+ manifest, and consent writes still need the backend. Measure the deployed
41
+ request path before promising a latency improvement.
42
+
43
+ Do not put secrets, visitor identifiers or consent records into a manifest.
44
+ Keep personalized init responses out of shared caches. Changing a policy also
45
+ requires a refresh strategy for cached or build-time manifests.
46
+
47
+ ## What does regular `/init` do?
48
+
49
+ `hosted({ url })` uses `${url}/init` for initialization and `${url}/subjects` for
50
+ consent submissions. The name `hosted` describes the transport protocol; the URL
51
+ can belong to Inth or your own c15t backend.
52
+
53
+ ```ts title="src/consent-mode.ts"
54
+ import { hosted } from 'c15t';
55
+
56
+ export function createConsentMode(backendURL: string) {
57
+ return hosted({ url: backendURL });
58
+ }
59
+ ```
60
+
61
+ Pass the factory to your adapter's `mode` option. For request rendering, use the
62
+ adapter's server helper and forward its prepared result to the browser. For
63
+ static output, initialize in the browser with a reachable external URL.
64
+
65
+ A regular backend `/init` request lets the backend resolve the visitor context.
66
+ A same-origin URL named `/api/c15t/init` can instead resolve from a cached
67
+ manifest in your application. The URL name alone does not tell you which path
68
+ runs.
69
+
70
+ ## How do transports and proxies differ?
71
+
72
+ A transport implements initialization, saving and optional record operations.
73
+ A proxy changes where HTTP requests travel. It does not change the policy
74
+ resolver or make personalized responses safe to cache.
75
+
76
+ For a same-origin init route that resolves a manifest, the hosted transport can
77
+ separate policy reads and record writes. With a backend rewrite mounted at
78
+ `/api/c15t`, a client mode can use:
79
+
80
+ ```ts title="src/consent-mode.ts"
81
+ import { hosted } from 'c15t';
82
+
83
+ export const mode = hosted({
84
+ url: '/api/c15t',
85
+ initURL: '/api/c15t/init',
86
+ assertDecisionInputs: true,
87
+ });
88
+ ```
89
+
90
+ The route must return the c15t init response contract. `assertDecisionInputs`
91
+ binds saves to the resolved policy when init did not return a signed policy
92
+ snapshot token. The backend can then reject a stale policy decision. Next.js
93
+ sets this option for you when `ConsentRoot` receives a `config` with
94
+ `initURL`.
95
+
96
+ The init route resolves policy; the backend rewrite forwards `/api/c15t/subjects`
97
+ and other record endpoints. Configure both if you choose this optional proxy
98
+ variant. The
99
+ [Next.js rewrite recipe](https://c15t.com/docs/frameworks/next/optimization#keep-browser-consent-requests-on-your-origin)
100
+ shows the configuration. A direct absolute backend URL works
101
+ without a rewrite.
102
+
103
+ This optional optimization keeps c15t requests on the app's origin and avoids a separate browser DNS lookup
104
+ and TLS connection to the consent backend. The app server still connects to
105
+ the upstream backend for manifest refreshes and consent writes. Vendor scripts
106
+ and vendor requests keep their own origins.
107
+
108
+ Set the absolute upstream endpoint through `C15T_BACKEND_URL` in Next.js server
109
+ configuration. The endpoint URL is public connection information, not a secret.
110
+ The browser uses `/api/c15t` without needing the upstream URL. A static export
111
+ cannot serve a Next.js route or rewrite at runtime; use the absolute Inth URL or
112
+ a proxy provided by the static host instead.
113
+
114
+ ## When should I use offline mode?
115
+
116
+ Not recommended for production environments. Use Inth or a self-hosted backend
117
+ for production policy and consent records.
118
+
119
+ `offline()` resolves bundled policy rules without an init request and acknowledges
120
+ saves locally. The runtime's persistence module stores the choice in browser
121
+ storage. There is no backend audit history, cross-device record service or IP
122
+ geolocation supplied by this transport.
123
+
124
+ Use your adapter's offline factory so its translations and provider context are
125
+ included. This React and Next.js example replaces the hosted mode in an existing
126
+ client provider:
127
+
128
+ ```ts title="src/consent-mode.ts"
129
+ import { offline } from 'c15t/react';
130
+
131
+ export const mode = offline();
132
+ ```
133
+
134
+ With no `policyRules`, the current offline transport uses the recommended rule
135
+ pack. Supplying `policyRules` replaces that pack. Unknown country and region are
136
+ real resolution inputs; offline mode does not discover a visitor's location.
137
+ Use [policy rules](https://c15t.com/docs/frameworks/next/concepts/policy-presets) to understand
138
+ matching and defaults, and test the missing-location case.
139
+
140
+ Offline mode is an explicit architecture choice, not an automatic fallback for
141
+ a failed Inth request. If hosted initialization fails before a policy resolves,
142
+ optional permissions remain denied and the stock prompt stays hidden. Observe
143
+ initialization failures instead of silently changing policy sources.
144
+
145
+ ## Can I provide my own transport?
146
+
147
+ `custom(transport)` accepts a `KernelTransport` with the v3 `init` and `save`
148
+ contract. It does not accept v2 endpoint handlers such as `setConsent`. Keep
149
+ policy resolution, record acknowledgments and failure behavior consistent with
150
+ the kernel contract. Prefer a built-in transport when your backend supports it.
151
+
152
+ ## Verify the selected path
153
+
154
+ Inspect browser and server requests separately. A server manifest fetch will
155
+ not appear in the browser's Network panel. On a warm manifest path, check that
156
+ page requests do not call the backend `/init`, a visitor's choice still reaches
157
+ the backend's `/subjects`, and policy changes become visible after the configured
158
+ refresh. In the recommended Next.js setup, the browser should call only
159
+ `/api/c15t` paths for consent HTTP traffic; inspect server logs to verify their
160
+ upstream destinations.
161
+
162
+ Test different locations, missing location headers, GPC, returning choices and
163
+ backend failure. See [verification](./verify-consent.md).
@@ -0,0 +1,63 @@
1
+ ---
2
+ title: Choose a deployment mode
3
+ description: Choose who runs your consent backend, then select manifest, init or
4
+ offline resolution for your deployment.
5
+ group: guides
6
+ ---
7
+
8
+ ## Use Inth for managed policy and records
9
+
10
+ Start with [Inth](https://inth.com) unless you need to operate the consent
11
+ service yourself or deliberately need only local browser records. Configure
12
+ policy rules and trusted origins in the project, then use its exact backend
13
+ endpoint in your framework setup.
14
+
15
+ | Backend ownership | Policy source | Record storage | Use when |
16
+ | ------------------------- | ------------------------------------------------------ | ---------------------------------------- | ------------------------------------------------------------------------- |
17
+ | Inth hosted service | Centrally managed policy through a manifest or `/init` | Browser records plus backend submissions | You want managed policy and consent records |
18
+ | Self-hosted c15t | Your backend's manifest or `/init` | Browser records plus your database | You need to operate the service and its infrastructure |
19
+ | Browser-only offline mode | Bundled `policyRules` | Browser persistence | Local development and tests. Not recommended for production environments. |
20
+
21
+ Hosted and self-hosted c15t use the same transport protocol. Switching who runs
22
+ the backend does not require switching from manifests to `/init`.
23
+
24
+ ## Choose data fetching separately
25
+
26
+ For Next.js deployments with a runtime server, use the
27
+ [manifest setup](https://c15t.com/docs/frameworks/next/data-fetching). It reuses public policy data
28
+ in your application while consent writes still go to Inth. Regular backend
29
+ `/init` is available when you want backend-owned request resolution or a simpler
30
+ browser setup. See [data fetching and transports](./data-fetching.md) for
31
+ the comparison, including custom transports and offline mode.
32
+
33
+ ## Match initialization to your application output
34
+
35
+ | Application output | Initial state | Required setup |
36
+ | ------------------ | ------------------------- | ----------------------------------------------------------- |
37
+ | Request SSR | Prepared for this visitor | Adapter request helper and matching client configuration |
38
+ | Static HTML or SPA | Resolved in the browser | Reachable external URLs or deliberately bundled local rules |
39
+
40
+ Request SSR can include the visitor's prompt in the initial HTML. Pass the
41
+ prepared records and policy resolution through to hydration. Do not convert
42
+ effective permissions into new stored choices.
43
+
44
+ Static HTML is shared across visitors. It cannot contain a choice resolved from
45
+ each visitor's cookies or geography at build time. A static site can still use
46
+ Inth through browser requests. A same-origin `/api/c15t` URL only works if a
47
+ service actually serves it; a Next.js static export does not run API routes.
48
+
49
+ A manifest contains reusable public policy data. A resolved init response and
50
+ personalized consent HTML belong to a request. Do not give them the same shared
51
+ cache treatment.
52
+
53
+ ## Handle initialization and storage failures
54
+
55
+ While no policy resolves, optional permissions stay denied and the stock
56
+ consent UI stays hidden. No banner can mean pending or failed initialization.
57
+ It does not mean permission to load analytics. Observe errors before changing
58
+ presentation, and do not silently switch to offline policy after a hosted
59
+ request fails.
60
+
61
+ Browser storage can also be unavailable. A working in-memory interaction does
62
+ not prove the choice survives reload. Use
63
+ [verification](./verify-consent.md) to test the actual deployment.
@@ -0,0 +1,68 @@
1
+ ---
2
+ title: Troubleshoot consent
3
+ description: Diagnose missing banners, early vendor requests, lost choices and
4
+ hydration differences.
5
+ group: guides
6
+ ---
7
+
8
+ ## Why is there no banner?
9
+
10
+ Inspect `resolution` and `promptRequirement` before changing styles. Pending or
11
+ failed initialization, no matching rule, a valid stored choice and a rule that
12
+ requires no prompt can all produce no banner for different reasons. A missing
13
+ stylesheet can also make rendered controls appear incorrectly.
14
+
15
+ Check the backend URL and Network response, then confirm the active policy for
16
+ the visitor's location. Do not solve missing UI by granting every category or
17
+ setting `enabled: false`: disabling the runtime permits optional loading.
18
+
19
+ ## Why does the UI disappear with a content blocker?
20
+
21
+ Check the browser Network panel for `ERR_BLOCKED_BY_CLIENT` or a failed dynamic
22
+ import. Older c15t builds used component filenames such as
23
+ `consent-dialog-*.js`, which some cookie-annoyance lists block. Update the c15t
24
+ packages and rebuild the app. Current component modules use neutral filenames;
25
+ public component imports stay the same. This also covers Vite development
26
+ requests used by TanStack Start and other Vite integrations.
27
+
28
+ Extensions can separately hide elements with cosmetic filters or block a
29
+ configured backend URL. Check the failed request or hidden element to distinguish
30
+ those cases from a missing component module.
31
+
32
+ ## Why does analytics run before a choice?
33
+
34
+ Check effective permission under the selected policy, then find every loader
35
+ for that vendor. Remove unconditional script tags, framework analytics plugins
36
+ and duplicate tag-manager entries. c15t's script registration only controls the
37
+ scripts registered with it.
38
+
39
+ Google helpers intentionally load with Consent Mode defaults. A Google request
40
+ is not by itself proof that its storage consent was granted. If your requirement
41
+ is no request at all, do not use an always-loaded helper unchanged.
42
+
43
+ ## Why does a choice disappear on reload?
44
+
45
+ Check whether persistence is disabled, browser storage is blocked, the origin
46
+ changed, or the receipt expired or no longer matches the current policy.
47
+ A development example with `persistence: false` deliberately resets on reload.
48
+ Do not "repair" persistence by saving permissions automatically on mount.
49
+
50
+ ## Why does hydration differ from server HTML?
51
+
52
+ Use the adapter's request helper and pass the returned configuration unchanged
53
+ to its boundary. Check that server and browser use the same backend and policy
54
+ inputs. A module-level mutable runtime on a server can share one visitor's state
55
+ with another request; create request-owned state instead.
56
+
57
+ ## Why does static hosting fail when development works?
58
+
59
+ A static host has no app server for init routes, proxies or server functions.
60
+ Use absolute external consent URLs or an explicitly local policy. Test the
61
+ production output with a static file server, not the framework dev server.
62
+
63
+ ## Why does customization do nothing?
64
+
65
+ Check the imported stylesheet, the correct token or slot, and which element
66
+ carries the state attribute. `data-variant` on a banner root is not a matching
67
+ attribute on its child card. Check cascade layers and the Tailwind version
68
+ before adding specificity. See [customization](../customization/overview.md).