@c15t/nextjs 2.1.0 → 2.2.1

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 (162) hide show
  1. package/AGENTS.md +155 -0
  2. package/README.md +31 -15
  3. package/client/components/integrations.js +3 -0
  4. package/dist/components/integrations/index.cjs +1 -0
  5. package/dist/components/integrations/index.js +1 -0
  6. package/dist/headless.cjs +1 -1
  7. package/dist/index.cjs +1 -1
  8. package/dist/libs/browser-initial-data.cjs +1 -1
  9. package/dist/libs/initial-data.cjs +1 -1
  10. package/dist/styles.tw3.css +1 -1
  11. package/dist/version.cjs +1 -1
  12. package/dist/version.js +1 -1
  13. package/dist-types/components/integrations/index.d.ts +1 -0
  14. package/dist-types/libs/browser-initial-data.d.ts +1 -1
  15. package/dist-types/version.d.ts +1 -1
  16. package/docs/README.md +155 -73
  17. package/docs/{building-headless-components.md → frameworks/next/building-headless-components.md} +3 -1
  18. package/docs/{callbacks.md → frameworks/next/callbacks.md} +3 -1
  19. package/docs/{components → frameworks/next/components}/consent-banner.md +10 -21
  20. package/docs/{components → frameworks/next/components}/consent-dialog-link.md +8 -5
  21. package/docs/frameworks/next/components/consent-dialog-trigger.md +202 -0
  22. package/docs/{components → frameworks/next/components}/consent-dialog.md +7 -15
  23. package/docs/frameworks/next/components/consent-manager-provider.md +327 -0
  24. package/docs/{components → frameworks/next/components}/consent-widget.md +8 -6
  25. package/docs/{components → frameworks/next/components}/dev-tools.md +9 -6
  26. package/docs/{components → frameworks/next/components}/frame.md +8 -9
  27. package/docs/{concepts → frameworks/next/concepts}/client-modes.md +4 -2
  28. package/docs/{concepts → frameworks/next/concepts}/consent-categories.md +1 -0
  29. package/docs/{concepts → frameworks/next/concepts}/consent-models.md +1 -0
  30. package/docs/{concepts → frameworks/next/concepts}/cookie-management.md +3 -3
  31. package/docs/{concepts → frameworks/next/concepts}/glossary.md +1 -0
  32. package/docs/{concepts → frameworks/next/concepts}/initialization-flow.md +1 -0
  33. package/docs/{concepts → frameworks/next/concepts}/policy-packs.md +1 -0
  34. package/docs/{headless.md → frameworks/next/headless.md} +3 -1
  35. package/docs/{hooks → frameworks/next/hooks}/use-color-scheme.md +1 -0
  36. package/docs/{hooks → frameworks/next/hooks}/use-consent-manager/checking-consent.md +3 -1
  37. package/docs/{hooks → frameworks/next/hooks}/use-consent-manager/location-info.md +3 -1
  38. package/docs/frameworks/next/hooks/use-consent-manager/overview.md +185 -0
  39. package/docs/{hooks → frameworks/next/hooks}/use-consent-manager/setting-consent.md +3 -1
  40. package/docs/{hooks → frameworks/next/hooks}/use-draggable.md +3 -1
  41. package/docs/{hooks → frameworks/next/hooks}/use-focus-trap.md +1 -0
  42. package/docs/{hooks → frameworks/next/hooks}/use-reduced-motion.md +3 -1
  43. package/docs/{hooks → frameworks/next/hooks}/use-ssr-status.md +6 -5
  44. package/docs/{hooks → frameworks/next/hooks}/use-text-direction.md +1 -0
  45. package/docs/frameworks/next/hooks/use-translations.md +55 -0
  46. package/docs/{iab → frameworks/next/iab}/consent-banner.md +9 -12
  47. package/docs/{iab → frameworks/next/iab}/consent-dialog.md +9 -14
  48. package/docs/{iab → frameworks/next/iab}/overview.md +4 -2
  49. package/docs/{iab → frameworks/next/iab}/use-gvl-data.md +3 -2
  50. package/docs/{iframe-blocking.md → frameworks/next/iframe-blocking.md} +8 -9
  51. package/docs/{internationalization.md → frameworks/next/internationalization.md} +13 -3
  52. package/docs/{network-blocker.md → frameworks/next/network-blocker.md} +13 -51
  53. package/docs/{optimization.md → frameworks/next/optimization.md} +5 -4
  54. package/docs/{policy-packs.md → frameworks/next/policy-packs.md} +3 -1
  55. package/docs/{quickstart.md → frameworks/next/quickstart.md} +26 -42
  56. package/docs/{script-loader.md → frameworks/next/script-loader.md} +72 -90
  57. package/docs/{server-side.md → frameworks/next/server-side.md} +12 -15
  58. package/docs/{styling → frameworks/next/styling}/classnames.md +3 -1
  59. package/docs/{styling → frameworks/next/styling}/color-scheme.md +3 -1
  60. package/docs/frameworks/next/styling/css-variables.md +53 -0
  61. package/docs/frameworks/next/styling/overview.md +299 -0
  62. package/docs/frameworks/next/styling/slots.md +94 -0
  63. package/docs/{styling → frameworks/next/styling}/tailwind.md +3 -1
  64. package/docs/frameworks/next/styling/tokens.md +156 -0
  65. package/docs/{troubleshooting.md → frameworks/next/troubleshooting.md} +3 -1
  66. package/docs/integrations/adobe-analytics.md +160 -0
  67. package/docs/integrations/ahrefs-analytics.md +15 -82
  68. package/docs/integrations/amplitude.md +230 -0
  69. package/docs/integrations/building-integrations.md +15 -181
  70. package/docs/integrations/clearbit.md +130 -0
  71. package/docs/integrations/cloudflare-web-analytics.md +15 -83
  72. package/docs/integrations/crisp.md +13 -87
  73. package/docs/integrations/databuddy.md +16 -85
  74. package/docs/integrations/fathom-analytics.md +15 -86
  75. package/docs/integrations/google-maps.md +263 -0
  76. package/docs/integrations/google-tag-manager.md +18 -86
  77. package/docs/integrations/google-tag.md +15 -84
  78. package/docs/integrations/heap.md +219 -0
  79. package/docs/integrations/hightouch.md +199 -0
  80. package/docs/integrations/hotjar.md +15 -83
  81. package/docs/integrations/intercom.md +13 -83
  82. package/docs/integrations/linkedin-insights.md +15 -82
  83. package/docs/integrations/logrocket.md +175 -0
  84. package/docs/integrations/matomo-analytics.md +13 -88
  85. package/docs/integrations/meta-pixel.md +33 -316
  86. package/docs/integrations/microsoft-clarity.md +15 -83
  87. package/docs/integrations/microsoft-uet.md +16 -83
  88. package/docs/integrations/mixpanel-analytics.md +15 -83
  89. package/docs/integrations/overview.md +55 -6
  90. package/docs/integrations/pirsch.md +142 -0
  91. package/docs/integrations/plausible-analytics.md +14 -97
  92. package/docs/integrations/posthog.md +26 -98
  93. package/docs/integrations/promptwatch.md +16 -82
  94. package/docs/integrations/reddit-pixel.md +27 -122
  95. package/docs/integrations/rudderstack.md +271 -0
  96. package/docs/integrations/rybbit-analytics.md +15 -94
  97. package/docs/integrations/segment.md +15 -82
  98. package/docs/integrations/snapchat-pixel.md +21 -102
  99. package/docs/integrations/tiktok-pixel.md +13 -81
  100. package/docs/integrations/umami-analytics.md +16 -88
  101. package/docs/integrations/vercel-analytics.md +13 -85
  102. package/docs/integrations/x-pixel.md +27 -102
  103. package/docs/integrations/youtube.md +193 -0
  104. package/docs/shared/concepts/client-modes.md +103 -0
  105. package/docs/shared/concepts/consent-categories.md +41 -0
  106. package/docs/shared/concepts/consent-models.md +72 -0
  107. package/docs/shared/concepts/cookie-management.md +88 -0
  108. package/docs/shared/concepts/glossary.md +24 -0
  109. package/docs/shared/concepts/initialization-flow.md +105 -0
  110. package/docs/shared/concepts/policy-packs.md +225 -0
  111. package/docs/shared/react/components/consent-banner.md +242 -0
  112. package/docs/shared/react/components/consent-dialog-link.md +45 -0
  113. package/docs/shared/react/components/consent-dialog-trigger.md +185 -0
  114. package/docs/shared/react/components/consent-dialog.md +119 -0
  115. package/docs/shared/react/components/consent-manager-provider.md +225 -0
  116. package/docs/shared/react/components/consent-widget.md +121 -0
  117. package/docs/shared/react/components/dev-tools.md +81 -0
  118. package/docs/shared/react/components/frame.md +52 -0
  119. package/docs/shared/react/guides/building-headless-components.md +110 -0
  120. package/docs/shared/react/guides/callbacks.md +89 -0
  121. package/docs/shared/react/guides/headless.md +31 -0
  122. package/docs/shared/react/guides/iframe-blocking.md +65 -0
  123. package/docs/shared/react/guides/internationalization.md +123 -0
  124. package/docs/shared/react/guides/network-blocker.md +72 -0
  125. package/docs/shared/react/guides/optimization.md +44 -0
  126. package/docs/shared/react/guides/policy-packs.md +173 -0
  127. package/docs/shared/react/guides/script-loader.md +311 -0
  128. package/docs/shared/react/hooks/use-color-scheme.md +31 -0
  129. package/docs/shared/react/hooks/use-consent-manager/checking-consent.md +95 -0
  130. package/docs/shared/react/hooks/use-consent-manager/location-info.md +96 -0
  131. package/docs/shared/react/hooks/use-consent-manager/overview.md +74 -0
  132. package/docs/shared/react/hooks/use-consent-manager/setting-consent.md +93 -0
  133. package/docs/shared/react/hooks/use-draggable.md +30 -0
  134. package/docs/shared/react/hooks/use-focus-trap.md +20 -0
  135. package/docs/shared/react/hooks/use-reduced-motion.md +33 -0
  136. package/docs/shared/react/hooks/use-ssr-status.md +16 -0
  137. package/docs/shared/react/hooks/use-text-direction.md +38 -0
  138. package/docs/shared/react/hooks/use-translations.md +15 -0
  139. package/docs/shared/react/iab/consent-banner.md +60 -0
  140. package/docs/shared/react/iab/consent-dialog.md +76 -0
  141. package/docs/shared/react/iab/overview.md +80 -0
  142. package/docs/shared/react/iab/use-gvl-data.md +21 -0
  143. package/docs/shared/react/styling/classnames.md +93 -0
  144. package/docs/shared/react/styling/color-scheme.md +35 -0
  145. package/docs/shared/react/styling/css-variables.md +53 -0
  146. package/docs/shared/react/styling/overview.md +261 -0
  147. package/docs/shared/react/styling/slots.md +93 -0
  148. package/docs/shared/react/styling/stylesheet-entrypoint.md +8 -0
  149. package/docs/shared/react/styling/tailwind.md +88 -0
  150. package/docs/shared/react/styling/tokens.md +155 -0
  151. package/docs/shared/troubleshooting.md +82 -0
  152. package/package.json +19 -10
  153. package/readme.json +14 -8
  154. package/docs/ai-agents.md +0 -111
  155. package/docs/components/consent-dialog-trigger.md +0 -103
  156. package/docs/components/consent-manager-provider.md +0 -425
  157. package/docs/hooks/use-consent-manager/overview.md +0 -420
  158. package/docs/hooks/use-translations.md +0 -118
  159. package/docs/styling/css-variables.md +0 -92
  160. package/docs/styling/overview.md +0 -457
  161. package/docs/styling/slots.md +0 -128
  162. package/docs/styling/tokens.md +0 -216
@@ -0,0 +1,193 @@
1
+ ---
2
+ title: YouTube
3
+ description: Keep YouTube iframes unmounted until consent with a
4
+ privacy-enhanced, lazy-loaded React or Next.js embed.
5
+ icon: youtube
6
+ group: integrations
7
+ ---
8
+ `YouTubeEmbed` is a renderable integration for React and Next.js. It uses c15t's
9
+ `Frame` consent boundary, so the YouTube iframe is not mounted and no YouTube
10
+ request is made until the configured consent category is allowed.
11
+
12
+ The component does not load the YouTube IFrame Player API. It is intended for
13
+ standard iframe embeds and keeps script readiness separate from iframe gating.
14
+
15
+ ## Integrate with c15t
16
+
17
+ `YouTubeEmbed` must render inside a `ConsentManagerProvider`. Complete the
18
+ [React quickstart](/docs/frameworks/react/quickstart) or
19
+ [Next.js quickstart](/docs/frameworks/next/quickstart) first.
20
+
21
+ **React**
22
+
23
+ ```tsx
24
+ import { YouTubeEmbed } from '@c15t/react';
25
+
26
+ export function ProductVideo() {
27
+ return (
28
+ <YouTubeEmbed
29
+ consentCategory="marketing"
30
+ params={{ controls: true, playsinline: true }}
31
+ title="Product overview"
32
+ videoId="dQw4w9WgXcQ"
33
+ />
34
+ );
35
+ }
36
+ ```
37
+
38
+ **Next.js**
39
+
40
+ ```tsx
41
+ 'use client';
42
+
43
+ import { YouTubeEmbed } from '@c15t/nextjs';
44
+
45
+ export function ProductVideo() {
46
+ return (
47
+ <YouTubeEmbed
48
+ consentCategory="marketing"
49
+ params={{ controls: true, playsinline: true }}
50
+ title="Product overview"
51
+ videoId="dQw4w9WgXcQ"
52
+ />
53
+ );
54
+ }
55
+ ```
56
+
57
+ `marketing` is the default category. Choose a different category only when it
58
+ matches the purpose of the embed and the policy presented to your users.
59
+
60
+ ## How c15t loads it
61
+
62
+ * **Before consent:** c15t renders a placeholder and does not mount the iframe.
63
+ * **After consent:** the iframe mounts with its final embed URL.
64
+ * **On revocation:** the `Frame` boundary unmounts the iframe, stopping the
65
+ embedded player and future requests from that document.
66
+ * **Loading behavior:** c15t reserves the final player size, shows a localized
67
+ loading state, and uses native iframe lazy loading by default.
68
+ * **Default layout:** the placeholder and player share a responsive 16:9,
69
+ borderless frame with a `200px` minimum height.
70
+ * **Privacy-enhanced mode:** URLs built from `videoId` use
71
+ `youtube-nocookie.com` by default.
72
+
73
+ Privacy-enhanced mode changes the YouTube host but does not replace consent
74
+ gating. Keep the iframe behind the category required by your privacy policy.
75
+
76
+ ## Build the embed URL
77
+
78
+ Prefer `videoId` when you control the video:
79
+
80
+ ```tsx
81
+ <YouTubeEmbed
82
+ consentCategory="marketing"
83
+ params={{
84
+ autoplay: false,
85
+ controls: true,
86
+ playsinline: true,
87
+ rel: false,
88
+ }}
89
+ start={36}
90
+ title="Quarterly product update"
91
+ videoId="dQw4w9WgXcQ"
92
+ />
93
+ ```
94
+
95
+ Boolean `params` are serialized as YouTube's `1` and `0` values. `start` is
96
+ serialized as the player's start time in seconds. If `params.start` is also
97
+ present, the top-level `start` prop takes precedence.
98
+
99
+ Set `privacyEnhanced={false}` only when you intentionally need the regular
100
+ `youtube.com` host.
101
+
102
+ ### Migrate an existing iframe URL
103
+
104
+ Use `src` when you already have a complete embed URL:
105
+
106
+ ```tsx
107
+ <YouTubeEmbed
108
+ consentCategory="marketing"
109
+ src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?start=36"
110
+ title="Quarterly product update"
111
+ />
112
+ ```
113
+
114
+ When `src` is provided, c15t uses it unchanged. TypeScript treats `src` and
115
+ `videoId` as mutually exclusive source modes: `start`, `params`, and
116
+ `privacyEnhanced` are available only with `videoId`.
117
+
118
+ ## Style the wrapper and iframe
119
+
120
+ `wrapperClassName` targets the consent-gated `Frame`. `className` and the
121
+ forwarded ref target the iframe itself.
122
+
123
+ The defaults are responsive and stable without utility classes. Override them
124
+ only when your layout needs a different aspect ratio or height:
125
+
126
+ ```tsx
127
+ <YouTubeEmbed
128
+ consentCategory="marketing"
129
+ frameProps={{ style: { aspectRatio: '4 / 3', minHeight: 280 } }}
130
+ style={{ borderRadius: 4 }}
131
+ title="Product overview"
132
+ videoId="dQw4w9WgXcQ"
133
+ />
134
+ ```
135
+
136
+ `frameProps.style` is merged after the wrapper defaults. The iframe fills that
137
+ wrapper, has no border, and inherits the wrapper radius by default.
138
+
139
+ ## Customize the placeholder
140
+
141
+ ```tsx
142
+ import { Frame, YouTubeEmbed } from '@c15t/react';
143
+
144
+ <YouTubeEmbed
145
+ consentCategory="marketing"
146
+ placeholder={
147
+ <Frame.Root>
148
+ <Frame.Title>Allow marketing consent to watch this video.</Frame.Title>
149
+ <Frame.Button category="marketing" />
150
+ </Frame.Root>
151
+ }
152
+ title="Product overview"
153
+ videoId="dQw4w9WgXcQ"
154
+ />
155
+ ```
156
+
157
+ Custom placeholders should explain why the content is blocked and provide a
158
+ clear way to change consent. Always give the iframe a meaningful `title`.
159
+
160
+ Use `loadingFallback` to replace the post-consent loading message and
161
+ `errorFallback` to replace the configuration error state. If neither `videoId`
162
+ nor `src` is supplied at runtime, the component renders that error state instead
163
+ of mounting an iframe.
164
+
165
+ Standard cross-origin iframes do not provide a reliable player-error signal.
166
+ `YouTubeEmbed` forwards the iframe's native `onError` when a browser emits it,
167
+ but player-level errors require the YouTube IFrame Player API and are outside
168
+ this iframe-only component.
169
+
170
+ ## Verify setup
171
+
172
+ 1. Clear saved consent and reload the page.
173
+ 2. Confirm there is no YouTube iframe or YouTube network request before consent.
174
+ 3. Grant the configured category and confirm exactly one iframe mounts.
175
+ 4. Confirm a `videoId` embed uses `youtube-nocookie.com` unless
176
+ `privacyEnhanced={false}`.
177
+ 5. Revoke consent and confirm the iframe is removed.
178
+ 6. Confirm the default 16:9 frame is borderless and reserves the same space at
179
+ mobile and desktop widths.
180
+
181
+ See YouTube's [embedded player parameters](https://developers.google.com/youtube/player_parameters)
182
+ for the supported query parameters.
183
+
184
+ ## Types
185
+
186
+ ### YouTubeEmbedProps
187
+
188
+ |Property|Value|
189
+ |:--|:--|
190
+ |Type Name|\`YouTubeEmbedProps\`|
191
+ |Source Path|\`./packages/react/src/components/integrations/youtube-embed.tsx\`|
192
+
193
+ \*ExtractedTypeTable: Could not extract "YouTubeEmbedProps" from "./packages/react/src/components/integrations/youtube-embed.tsx" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
@@ -0,0 +1,103 @@
1
+ ---
2
+ title: Client Modes
3
+ description: Reference page for client modes.
4
+ group: reference
5
+ ---
6
+ c15t supports three client modes that determine how consent data is stored and synchronized. Choose the mode that matches your infrastructure:
7
+
8
+ * **Hosted mode** - Recommended for production. Backend-backed consent with geolocation, centralized policy resolution, audit history, and offline fallback.
9
+ * **Offline mode** - Browser-only storage with no network requests. Best for local development, demos, static deployments, or controlled fallback scenarios.
10
+ * **Custom mode** - Bring your own backend with custom endpoint handlers
11
+
12
+ > ⚠️ **Warning:**
13
+ > If you need durable consent records, server-side enforcement, or automatic jurisdiction detection, use hosted mode. Offline mode cannot provide those guarantees because consent lives only in the browser.
14
+
15
+ <span id="c15t-mode" />
16
+
17
+ ## Hosted Mode (Recommended)
18
+
19
+ The default mode. Connects to a c15t backend for full consent lifecycle management. We recommend using [inth.com](https://inth.com) for a fully managed experience, but you can [self-host](/docs/self-host) as well.
20
+
21
+ > ℹ️ **Info:**
22
+ > mode: 'hosted' is the preferred value. The legacy alias mode: 'c15t' is still supported for backward compatibility.
23
+
24
+ **What happens:**
25
+
26
+ 1. On page load, the client calls `/init` to fetch geolocation, jurisdiction, localized translation strings
27
+ 2. When the user grants or changes consent, it is saved locally before being synced to the backend.
28
+ 3. If the backend is unreachable, it falls back to Offline mode and re-syncs with the backend when it's available
29
+
30
+ **Configuration:**
31
+
32
+ * `backendURL` (required) - API endpoint path
33
+
34
+ **Why it is the default for production:**
35
+
36
+ * The backend stays the source of truth for policy, translations, and jurisdiction logic
37
+ * Consent decisions can be stored beyond the current browser session for audit and support workflows
38
+ * Server-side systems can preload consent-aware behavior instead of waiting for client-only storage
39
+ * If the backend is temporarily unavailable, c15t can fall back locally and re-sync later
40
+
41
+ **Best for:** Production apps that need geolocation-based jurisdiction detection, consent record storage, and compliance audit trails.
42
+
43
+ ## Offline Mode
44
+
45
+ No network requests. Consent is stored entirely in the browser using localStorage and cookies.
46
+
47
+ **What happens:**
48
+
49
+ 1. Default jurisdiction is GDPR unless manually set via `overrides`
50
+ 2. Consent preferences persist locally only
51
+ 3. No server-side consent records or analytics
52
+
53
+ > ℹ️ **Info:**
54
+ > Important: Offline mode still stores consent locally (cookie + localStorage). It only skips backend storage and sync.
55
+
56
+ ### Consequences of Browser-Only Storage
57
+
58
+ If consent is not stored at all (for example, storage is blocked or frequently cleared):
59
+
60
+ * Users are treated as new visitors and must re-consent repeatedly
61
+ * Preferences are lost across browser resets, private sessions, and device changes
62
+ * You have no reliable audit evidence to prove prior consent choices
63
+ * Support and compliance teams have no centralized visibility into consent history by default
64
+ * Server-side systems cannot apply prior consent decisions before client initialization
65
+
66
+ **Trade-offs:**
67
+
68
+ * No automatic geolocation or jurisdiction detection
69
+ * No consent audit trail
70
+ * No centralized policy or translation updates without shipping frontend changes
71
+ * No cross-device sync
72
+ * No server-side visibility before client initialization
73
+ * Works without any backend infrastructure
74
+
75
+ **Best for:** Local development, Storybook/static demos, resilience fallback, or simpler sites that explicitly accept browser-only consent storage.
76
+
77
+ ## Custom Mode
78
+
79
+ Bring your own backend. You provide handler functions for each consent endpoint, and c15t calls them instead of making HTTP requests.
80
+
81
+ **What happens:**
82
+
83
+ 1. On page load, the client calls your endpoint handler to fetch geolocation, jurisdiction, localized translation strings
84
+ 2. When the user grants or changes consent, it is saved locally before being synced to the backend.
85
+ 3. If one of your handlers fails, c15t returns a handler error and keeps local consent state, but automatic offline fallback and retry queue behavior is not provided for custom handlers by default
86
+
87
+ This lets you integrate c15t with any existing API - your CRM, your own consent database, or a third-party compliance service.
88
+
89
+ **Best for:** Teams with existing consent infrastructure that want c15t's frontend without its backend.
90
+
91
+ ## Choosing a Mode
92
+
93
+ |Feature|Hosted|Offline|Custom|
94
+ |--|--|--|--|
95
+ |Geolocation|Automatic|Manual via overrides|Your implementation|
96
+ |Policy source of truth|Backend-managed|Bundled into the frontend|Your implementation|
97
+ |Consent sync|API|Local only|Your implementation|
98
+ |Audit trail|Backend records|Not available|Your implementation|
99
+ |Server-side consent awareness|Supported|Not available|Your implementation|
100
+ |SSR data|Supported|Not available|Your implementation|
101
+ |Analytics|Built-in|Not available|Your implementation|
102
+ |Infrastructure|c15t backend|None|Your backend|
103
+ |Setup effort|Minimal|Zero|Moderate|
@@ -0,0 +1,41 @@
1
+ ---
2
+ title: Consent Categories
3
+ description: Reference page for consent categories.
4
+ group: reference
5
+ ---
6
+ c15t organizes tracking technologies into five consent categories that align with GDPR and ePrivacy Directive requirements. Rather than asking users to approve or deny individual cookies or scripts, each category groups related tracking purposes together so users can make meaningful, informed choices about how their data is used.
7
+
8
+ > ℹ️ **Info:**
9
+ > Why categories, not cookie lists? Many consent banners list individual cookie names like \_ga, \_gid, or \_fbp. This is counterproductive:Technical names are meaningless to users — nobody knows what \_gid does by reading its name.Information overload drives "accept all" — a wall of cookie names pushes users toward dismissing the banner as fast as possible, which is the opposite of informed consent.Purpose is what matters — privacy regulations (GDPR, ePrivacy) require clear information about the purposes of data processing, not a cookie-by-cookie inventory.Cookie lists go stale — third-party scripts change their cookie names across versions, creating a maintenance burden that provides no real transparency.c15t's category-based approach — "measurement", "marketing", "experience" — communicates purpose directly. Users understand why data is collected, not how it is stored.
10
+
11
+ ## The Five Categories
12
+
13
+ |Category|Default|Toggleable|Description|
14
+ |--|--|--|--|
15
+ |`necessary`|`true`|No|Strictly necessary to operate or deliver the service|
16
+ |`functionality`|`false`|Yes|Basic interactions and functionalities|
17
+ |`experience`|`false`|Yes|Improve quality of user experience|
18
+ |`measurement`|`false`|Yes|Measure traffic and analyze behavior|
19
+ |`marketing`|`false`|Yes|Deliver personalized ads or marketing content|
20
+
21
+ The `necessary` category has `disabled: true` set internally, which prevents the user from toggling it off in the consent UI. All other categories can be freely toggled by the user.
22
+
23
+ Note that all categories except `necessary` have `display: false` by default. A category appears in the consent UI only if you include it in `consentCategories`. Categories not listed are hidden from the UI, but they still exist in consent state and may be affected by model-level behavior (for example, auto-grant in `opt-out` or `null` model flows).
24
+
25
+ ## Configuring Categories
26
+
27
+ The `consentCategories` array controls which consent categories are presented to the user in the consent UI. Only categories you list in this array will appear as toggleable options in the consent banner or modal.
28
+
29
+ The `necessary` category is always implicitly included even if you do not add it to the array. You never need to worry about accidentally omitting it -- c15t ensures it is always present and always enabled.
30
+
31
+ For example, if you set:
32
+
33
+ ```
34
+ consentCategories: ['necessary', 'measurement', 'marketing']
35
+ ```
36
+
37
+ then only those three categories will show toggles in the consent UI. The `functionality` and `experience` categories will not appear as user-configurable toggles.
38
+
39
+ In `opt-in`/`iab` flows, hidden categories usually remain `false` unless you explicitly set them. In `opt-out`/`null` flows, categories may be auto-granted even when hidden.
40
+
41
+ This gives you precise control over which consent choices to present to your users. A simple blog that only runs an analytics script might only need `measurement`. A media site with ad integrations would include `marketing`. A SaaS application with personalization features might add `experience` and `functionality` as well. You choose what is relevant to your site and c15t handles the rest - storing consent state, exposing it through hooks, and ensuring the right categories are active based on the user's choices.
@@ -0,0 +1,72 @@
1
+ ---
2
+ title: Consent Models
3
+ description: Reference page for consent models.
4
+ group: reference
5
+ ---
6
+ c15t supports four consent models that control how consent defaults, banner visibility, and category gating behave:
7
+
8
+ |Model|Philosophy|Banner|Categories default to|
9
+ |--|--|--|--|
10
+ |`opt-in`|Explicit consent required|Blocking banner|`false` (except `necessary`)|
11
+ |`opt-out`|Processing allowed by default|Non-blocking notice|`true` (all granted)|
12
+ |`iab`|IAB TCF 2.3 for programmatic ads|TCF banner|Managed by TCF framework|
13
+ |`null`|No regulation detected|No banner|`true` (all auto-granted)|
14
+
15
+ There are two ways c15t determines which model applies:
16
+
17
+ 1. **Policy packs** (recommended) — you explicitly set the model per region in a `PolicyConfig`. This gives you full control over which regions get which model. See [Policy Packs](/docs/frameworks/react/concepts/policy-packs).
18
+
19
+ 2. **Automatic jurisdiction mapping** (legacy default) — when no policy pack is configured, c15t detects the visitor's jurisdiction via geolocation and maps it to a model using the table below. This still works but gives you less control over categories, UI, and scope.
20
+
21
+ > ℹ️ **Info:**
22
+ > When using policy packs, the consent.model field in each policy directly sets the model — the automatic jurisdiction mapping is bypassed for that request.
23
+
24
+ ## The Four Models
25
+
26
+ ### Opt-in
27
+
28
+ The strictest consent model, used for GDPR and similar regulations that require explicit, affirmative consent before any non-essential data processing occurs. All consent categories except `necessary` default to `false`. A consent banner must be shown before any tracking scripts load.
29
+
30
+ Applies to: EU (GDPR), UK (UK GDPR), Switzerland, Brazil (LGPD), Japan (APPI), South Korea (PIPA), Quebec (Law 25). Also the fallback for unknown jurisdiction codes.
31
+
32
+ ### Opt-out
33
+
34
+ Used for CCPA-style regulations where data processing is permitted by default until the user exercises their right to opt out. All consent categories default to `true`. A blocking banner is not required — the typical pattern is a non-intrusive notice or footer link.
35
+
36
+ Applies to: California (CCPA), Canada (PIPEDA), Australia.
37
+
38
+ When the policy has `consent.gpc: true`, the browser's Global Privacy Control signal (`Sec-GPC: 1` or `navigator.globalPrivacyControl`) is respected — `marketing` and `measurement` are denied while other categories remain granted. The built-in California presets enable this by default. See [Policy Packs — GPC](/docs/frameworks/react/concepts/policy-packs#gpc) for details.
39
+
40
+ ### IAB
41
+
42
+ IAB Transparency and Consent Framework (TCF) 2.3 mode for programmatic advertising compliance. Only activates when two conditions are met: the jurisdiction is `GDPR` or `UK_GDPR`, and `iab.enabled` is `true` in your configuration.
43
+
44
+ When active, IAB mode generates TC strings, registers the `__tcfapi` CMP API, and works with the Global Vendor List (GVL) for machine-readable consent signals. If `iab.enabled` is not set, GDPR jurisdictions fall back to standard opt-in.
45
+
46
+ ### null
47
+
48
+ Returned when no jurisdiction is detected (`NONE` or `null`). No banner is displayed. On first visit, all categories are auto-granted.
49
+
50
+ ## Jurisdiction Mapping
51
+
52
+ When no policy pack is configured, c15t maps jurisdictions to models automatically:
53
+
54
+ |Jurisdiction Code|Region|Consent Model|
55
+ |--|--|--|
56
+ |`GDPR`|European Union|opt-in|
57
+ |`UK_GDPR`|United Kingdom|opt-in|
58
+ |`CH`|Switzerland|opt-in|
59
+ |`BR`|Brazil (LGPD)|opt-in|
60
+ |`APPI`|Japan|opt-in|
61
+ |`PIPA`|South Korea|opt-in|
62
+ |`PIPEDA`|Canada (excl. Quebec)|opt-out|
63
+ |`QC_LAW25`|Quebec, Canada|opt-in|
64
+ |`CCPA`|California, USA|opt-out|
65
+ |`AU`|Australia|opt-out|
66
+ |`NONE`|No jurisdiction|null|
67
+ |*(unknown)*|Any other|opt-in|
68
+
69
+ **IAB override:** If `iab.enabled: true` and the jurisdiction is `GDPR` or `UK_GDPR`, the model becomes `'iab'` instead of `'opt-in'`. This override only applies to those two jurisdictions.
70
+
71
+ > ℹ️ **Info:**
72
+ > With policy packs, you set the model explicitly per policy — the automatic mapping above is only used as a fallback when no policy pack is configured, or for non-policy-pack features like auto-granting in opt-out jurisdictions.
@@ -0,0 +1,88 @@
1
+ ---
2
+ title: Cookie Management
3
+ description: Reference page for cookie management.
4
+ group: reference
5
+ ---
6
+ Cookie management is the most commonly misunderstood part of consent. A critical distinction: **c15t does not manage all cookies on your site.** It controls what scripts, iframes, and network requests are allowed to load - and those third-party resources are what set most cookies.
7
+
8
+ Understanding this distinction is key to building a compliant consent flow: c15t gates the sources of cookies, not the cookies themselves.
9
+
10
+ ## What Actually Sets Cookies
11
+
12
+ There are four sources of cookies on a typical website:
13
+
14
+ **1. c15t itself**
15
+ c15t stores the user's consent state in a `c15t` cookie (and mirrors it to localStorage). This cookie records which categories the user consented to, when they consented, and their subject ID. This is a strictly necessary cookie - it exists so the site remembers the user's consent choice.
16
+
17
+ **2. Third-party scripts**
18
+ When you load a tracking script (Google Analytics, Meta Pixel, etc.), that script sets its own cookies. Google Analytics creates `_ga` and `_gid` cookies. Meta creates `_fbp` and `_fbc`. These cookies are set by the script's code running in the browser - c15t prevents them by not loading the script until the user consents.
19
+
20
+ **3. Embedded iframes**
21
+ YouTube embeds, social media widgets, and other iframes can set cookies via their embedded content. c15t's iframe blocker replaces iframes with placeholders until consent is granted, preventing these cookies from being set.
22
+
23
+ **4. Network requests**
24
+ Server responses can include `Set-Cookie` headers. If your page makes requests to third-party APIs or CDNs, those responses may set cookies. c15t's network blocker can intercept `fetch` and `XMLHttpRequest` calls to prevent these requests from happening without consent.
25
+
26
+ > ⚠️ **Warning:**
27
+ > Don't list these cookies in your banner. The cookie names above (\_ga, \_gid, \_fbp, \_fbc) are implementation details — they matter for developers understanding how tracking works, but they should not be exposed to end users in your consent UI. Users don't know what \_ga means, and listing it doesn't help them make an informed choice. Instead, use purpose-based consent categories like "measurement" or "marketing" that communicate why data is collected, not how it is stored.
28
+
29
+ ## Why Revoking Consent Requires a Page Reload
30
+
31
+ When a user revokes consent for a category (e.g., turns off "measurement" after previously granting it), c15t reloads the page by default. This is not a limitation - it's the only reliable approach.
32
+
33
+ **Why you can't just delete third-party cookies from JavaScript:**
34
+
35
+ * **`httpOnly` cookies** - Many tracking cookies are set with the `httpOnly` flag, which prevents JavaScript from reading or deleting them. Only the server that set them can remove them.
36
+ * **Domain restrictions** - Cookies set on `.google.com` or `.facebook.com` can only be deleted by those domains. Your JavaScript running on `yourdomain.com` has no access.
37
+ * **Alternative storage** - Some scripts also write to `localStorage`, `sessionStorage`, `IndexedDB`, or even Web Workers. Cleaning up all possible storage locations is impractical.
38
+ * **In-memory state** - A loaded script has already executed. Its event listeners, timers, and in-memory data persist until the page unloads. You can't "unrun" JavaScript.
39
+
40
+ **The reliable solution: don't load the scripts in the first place.** A page reload creates a fresh execution context. On the fresh page, c15t reads the updated consent state and simply never loads the scripts that lost consent. No script means no cookies, no tracking, no in-memory state.
41
+
42
+ **When reload does NOT happen:**
43
+
44
+ * When a user is declining consent for the **first time** (no prior consent existed, so no scripts were loaded to clean up)
45
+ * When `reloadOnConsentRevoked` is set to `false`
46
+ * When the user is only **adding** consent (no revocations)
47
+
48
+ ## The Revocation Flow
49
+
50
+ When a user revokes consent, the following sequence occurs:
51
+
52
+ **Simplified**
53
+
54
+ 1. **User revokes consent** — e.g. turns off "measurement" in the consent dialog
55
+ 2. **New consent saved** — updated preferences are written to cookies and localStorage
56
+ 3. **Pending sync stored** — the API update is deferred to localStorage (`c15t:pending-consent-sync`)
57
+ 4. **Page reloads** — a fresh execution context ensures revoked scripts never load
58
+ 5. **Fresh init** — c15t reads updated consent; scripts without consent are never loaded
59
+ 6. **Deferred API sync** — the pending consent change is sent to the backend and cleared from localStorage
60
+
61
+ **Sequence Diagram**
62
+
63
+ ```mermaid
64
+ sequenceDiagram
65
+ participant User
66
+ participant UI as Consent UI
67
+ participant Store as Consent Store
68
+ participant Storage as Cookie + localStorage
69
+ participant API as c15t Backend
70
+ participant Browser
71
+
72
+ User->>UI: Revokes "measurement" consent
73
+ UI->>Store: saveConsents({ type: 'custom' })
74
+ Store->>Store: shouldReloadOnConsentChange() → true
75
+ Store->>Storage: Save new consent state
76
+ Store->>Storage: Store PendingConsentSync in localStorage
77
+ Store->>Browser: onBeforeConsentRevocationReload callback
78
+ Store->>Browser: window.location.reload()
79
+ Browser->>Browser: Fresh page load
80
+ Browser->>Storage: Read consent state
81
+ Browser->>Store: Initialize with updated consents
82
+ Note over Store: Scripts without consent are never loaded
83
+ Store->>Storage: Read PendingConsentSync
84
+ Store->>API: Sync consent to backend
85
+ Store->>Storage: Clear PendingConsentSync
86
+ ```
87
+
88
+ **Key detail:** The API sync happens *after* the reload, not before. This ensures the page reloads as fast as possible. The pending sync data is stored in localStorage under the key `c15t:pending-consent-sync` and is picked up by the fresh page's initialization.
@@ -0,0 +1,24 @@
1
+ ---
2
+ title: Glossary
3
+ description: Reference page for glossary.
4
+ group: reference
5
+ ---
6
+ ### Core Terms
7
+
8
+ |Term|Definition|
9
+ |--|--|
10
+ |`subjectId`|Client-generated device/browser identifier (`sub_xxx`). Stored in the `c15t` cookie. Created on first consent save.|
11
+ |`externalId`|Your authenticated user's ID (from Clerk, Auth0, etc.), linked via `identifyUser()`. Connects a device to a user account.|
12
+ |`consents`|The **saved** consent state — `Record<string, boolean>` mapping categories to granted/denied. Used for gating scripts, iframes, and network requests.|
13
+ |`selectedConsents`|**Unsaved** toggle state — what the user has toggled in the dialog but hasn't submitted yet. Becomes `consents` after save.|
14
+ |`mode`|Client operating mode: `'hosted'` (full backend), `'offline'` (local only), or `'custom'` (bring your own handlers). Legacy alias: `'c15t'`. Set once in provider config. See [Client Modes](/docs/frameworks/react/concepts/client-modes).|
15
+ |`model`|Consent regulatory model derived from jurisdiction: `'opt-in'`, `'opt-out'`, `'iab'`, or `null`. See [Consent Models](/docs/frameworks/react/concepts/consent-models).|
16
+
17
+ ### Regulatory Terms
18
+
19
+ |Term|Definition|
20
+ |--|--|
21
+ |`jurisdiction`|A privacy regulation code (e.g., `GDPR`, `CCPA`, `PIPEDA`, `QC_LAW25`) detected from the user's geolocation. Maps to a consent model. See [Consent Models](/docs/frameworks/react/concepts/consent-models) for the full mapping table.|
22
+ |GPC|Global Privacy Control — a browser signal (`Sec-GPC: 1`) indicating the user opts out of data sale/sharing. Honored when a policy sets `consent.gpc: true` (enabled by default in California presets).|
23
+ |TCF|IAB Transparency and Consent Framework (v2.3) — a standard for programmatic advertising consent in GDPR jurisdictions. See [IAB TCF](/docs/frameworks/react/iab/overview).|
24
+ |GVL|Global Vendor List — an IAB-maintained registry of ad-tech vendors and their declared purposes, used by the TCF consent flow.|
@@ -0,0 +1,105 @@
1
+ ---
2
+ title: Initialization Flow
3
+ description: Reference page for initialization flow.
4
+ group: reference
5
+ ---
6
+ When the consent provider mounts, it creates a cached consent runtime, reads any stored consent from the browser, fetches the resolved policy from the backend (or uses SSR/offline data), and decides whether to show the banner. This entire sequence completes before the first meaningful consent-aware render.
7
+
8
+ ## Lifecycle Sequence
9
+
10
+ **Simplified**
11
+
12
+ 1. **Provider mounts** — creates (or retrieves from cache) a consent runtime and store
13
+ 2. **Check stored consent** — reads existing consent from cookies / localStorage; if found and the policy fingerprint hasn't changed, the banner stays hidden
14
+ 3. **Fetch init data** — calls the backend `GET /init` (or uses SSR/offline data) for the resolved policy, location, and translations
15
+ 4. **Apply resolved policy** — the backend resolves the policy from your [policy pack](/docs/frameworks/react/concepts/policy-packs) based on visitor geo (region → country → fallback → default). The response includes the consent model, categories, UI mode, and a material fingerprint. If no policy pack is configured, the legacy jurisdiction-to-model mapping is used instead.
16
+ 5. **Decide banner visibility** — shows the banner only if no prior consent exists, the resolved policy requires it (`ui.mode` is `banner` or `dialog`), or the policy fingerprint changed since last consent
17
+ 6. **Gating enforced** — scripts, iframes, and network requests tagged with a consent category are blocked until that category is granted
18
+ 7. **User interacts** — choices are persisted to storage, synced to the backend (with `policySnapshotToken` if configured), and blocked scripts/iframes load immediately after consent is granted
19
+
20
+ **Sequence Diagram**
21
+
22
+ ```mermaid
23
+ sequenceDiagram
24
+ participant Provider as ConsentManagerProvider
25
+ participant Store as Consent Store
26
+ participant Storage as localStorage / Cookie
27
+ participant API as c15t Backend
28
+ participant UI as Banner / Dialog
29
+ participant Scripts as Script Loader
30
+
31
+ Provider->>Store: getOrCreateConsentRuntime()
32
+ Store->>Storage: getStoredConsent()
33
+ alt Stored consent exists
34
+ Storage-->>Store: consentInfo + consents
35
+ Store->>Store: activeUI = 'none'
36
+ else No stored consent
37
+ Store->>Store: isLoadingConsentInfo = true
38
+ end
39
+
40
+ Store->>Store: initConsentManager()
41
+ Store->>Storage: Check pending consent sync
42
+ opt Pending sync from revocation reload
43
+ Store->>API: Deferred setConsent() (non-blocking)
44
+ end
45
+
46
+ alt SSR data provided
47
+ Store->>Store: tryUseSSRData()
48
+ else No SSR data
49
+ Store->>API: GET /init
50
+ API-->>Store: policy, policyDecision, location, translations
51
+ end
52
+
53
+ Store->>Store: Apply resolved policy (model, categories, ui.mode)
54
+ Store->>Store: Check fingerprint change → re-prompt if needed
55
+ Store->>Store: Set activeUI, auto-grant if opt-out/none
56
+
57
+ alt User has no prior consent or policy changed
58
+ UI->>UI: Banner / Dialog appears (per policy ui.mode)
59
+ UI->>Store: saveConsents({ type })
60
+ Store->>Storage: Persist consent + subjectId + fingerprint
61
+ Store->>Scripts: updateScripts(), updateIframes(), updateNetwork()
62
+ Store->>API: POST /subjects + policySnapshotToken (non-blocking)
63
+ end
64
+ ```
65
+
66
+ ## How It Works
67
+
68
+ **Mount** — When the provider renders, it creates (or retrieves from cache) a consent runtime and store. Any existing consent is read from localStorage/cookies immediately. If consent already exists and the policy fingerprint matches, the banner stays hidden and gating rules apply right away. See [Client Modes](/docs/frameworks/react/concepts/client-modes) for how the mode affects runtime creation.
69
+
70
+ **Init** — The store fetches the resolved policy, location, and translation data. In hosted mode this calls `GET /init` on your backend; in offline mode it resolves from `offlinePolicy.policyPacks` locally. If SSR data was passed to the provider, the network fetch is skipped entirely. See [Server-Side Utilities](/docs/frameworks/react/server-side) for SSR setup.
71
+
72
+ **Policy resolution** — When [policy packs](/docs/frameworks/react/concepts/policy-packs) are configured, the backend resolves the right policy for the visitor based on their geo-location (region → country → fallback → default). The resolved policy determines the consent model (`opt-in`, `opt-out`, `iab`, or `none`), which categories are in scope, and what UI to show. For `opt-out` and `none` models, all categories are auto-granted — unless the resolved policy has `consent.gpc: true` and the browser sends a Global Privacy Control signal, in which case `marketing` and `measurement` are denied. If no policy pack is configured, the legacy jurisdiction-to-model mapping is used instead. See [Consent Models](/docs/frameworks/react/concepts/consent-models) for details.
73
+
74
+ **Re-prompting** — If the resolved policy's material fingerprint differs from the fingerprint stored with the user's last consent, the banner is shown again. This happens automatically when you change consent-affecting fields (model, categories, scope mode, allowed actions). Presentation-only changes do not trigger re-prompts. See [Policy Packs — Re-Prompting](/docs/frameworks/react/concepts/policy-packs#re-prompting) for details.
75
+
76
+ **Save** — When the user interacts with the banner or dialog, their choices are persisted to localStorage/cookies and synced to the backend (along with the `policySnapshotToken` if snapshot signing is configured). Script, iframe, and network gating rules update immediately based on the new consent state. See the [Script Loader](/docs/frameworks/react/script-loader), [Iframe Blocking](/docs/frameworks/react/iframe-blocking), and [Network Blocker](/docs/frameworks/react/network-blocker) guides for gating details.
77
+
78
+ **Revocation** — If a user revokes a previously granted category, the page reloads by default to ensure a clean execution environment. The API sync is deferred to the fresh page load. See [Cookie Management](/docs/frameworks/react/concepts/cookie-management) for revocation and persistence details.
79
+
80
+ ## When Does the Banner Show?
81
+
82
+ The banner appears when any of these conditions are true:
83
+
84
+ 1. **No existing consent** — the user has never consented (or their consent was cleared), **and** the resolved policy requires a UI (`ui.mode` is `banner` or `dialog`, or the model is `opt-in` or `iab`)
85
+ 2. **Policy changed** — the material policy fingerprint differs from the fingerprint stored with the user's last consent (re-prompting)
86
+ 3. **Storage is accessible** — the browser allows localStorage (not blocked in private mode)
87
+
88
+ If the resolved model is `none` or `opt-out` (and `ui.mode` is `none`), consents are auto-granted and the banner never appears. See [Consent Models](/docs/frameworks/react/concepts/consent-models) and [Policy Packs](/docs/frameworks/react/concepts/policy-packs) for details.
89
+
90
+ ## Debugging the Lifecycle
91
+
92
+ Use the DevTools panel and callbacks to inspect each step of the initialization flow. `onConsentSet` is the broad lifecycle signal; `onConsentChanged` and `subscribeToConsentChanges()` are the change-only signals for explicit post-init saves.
93
+
94
+ |Step|DevTools Panel|Callback|What to check|
95
+ |--|--|--|--|
96
+ |Init / SSR hydration|Location|`onBannerFetched`|jurisdiction, countryCode, regionCode populated?|
97
+ |Policy resolution|Policy|`onBannerFetched`|`policyId`, `matchedBy`, `fingerprint` in policyDecision|
98
+ |Model resolution|Location|`onBannerFetched`|`model` value matches the resolved policy|
99
+ |Banner visibility|Consents|—|`activeUI` in store state; does policy `ui.mode` require it?|
100
+ |Re-prompting|Policy|—|Fingerprint mismatch between stored and resolved policy?|
101
+ |Consent save|Consents + Events|`onConsentSet`|`preferences` object in callback payload|
102
+ |Change-only integrations|Events|`onConsentChanged` or `subscribeToConsentChanges()`|`allowedCategories`, `deniedCategories`, and previous values only when a real save changed preferences|
103
+ |Script loading|Scripts|`onConsentSet`|Script IDs and their load/blocked status|
104
+ |Reload on revocation|Events|`onBeforeConsentRevocationReload`|Fires before reload; check localStorage for `c15t:pending-consent-sync`|
105
+ |Deferred sync|Events|`onError` (if sync fails)|After reload, check Events panel for successful API call|