@c15t/nextjs 2.0.0-rc.1 → 2.0.0-rc.12

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 (98) hide show
  1. package/README.md +10 -3
  2. package/client/components/consent-dialog-link.js +3 -0
  3. package/dist/headless.cjs +1 -1
  4. package/dist/iab/styles.css +12 -0
  5. package/dist/iab/styles.tw3.css +14 -0
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/libs/browser-initial-data.cjs +1 -0
  9. package/dist/libs/browser-initial-data.js +1 -0
  10. package/dist/libs/initial-data.cjs +1 -1
  11. package/dist/libs/initial-data.js +1 -1
  12. package/dist/styles.css +10 -0
  13. package/dist/styles.tw3.css +13 -0
  14. package/dist/types.cjs +1 -1
  15. package/dist/version.cjs +1 -1
  16. package/dist/version.js +1 -1
  17. package/{dist → dist-types}/headless.d.ts +0 -1
  18. package/{dist → dist-types}/index.d.ts +3 -2
  19. package/dist-types/libs/browser-initial-data.d.ts +9 -0
  20. package/{dist → dist-types}/libs/initial-data.d.ts +7 -2
  21. package/dist-types/types.d.ts +38 -0
  22. package/dist-types/version.d.ts +1 -0
  23. package/docs/README.md +73 -0
  24. package/docs/building-headless-components.md +377 -0
  25. package/docs/callbacks.md +184 -0
  26. package/docs/components/consent-banner.md +269 -0
  27. package/docs/components/consent-dialog-link.md +59 -0
  28. package/docs/components/consent-dialog-trigger.md +103 -0
  29. package/docs/components/consent-dialog.md +177 -0
  30. package/docs/components/consent-manager-provider.md +425 -0
  31. package/docs/components/consent-widget.md +133 -0
  32. package/docs/components/dev-tools.md +63 -0
  33. package/docs/components/frame.md +73 -0
  34. package/docs/concepts/client-modes.md +175 -0
  35. package/docs/concepts/consent-categories.md +97 -0
  36. package/docs/concepts/consent-models.md +116 -0
  37. package/docs/concepts/cookie-management.md +122 -0
  38. package/docs/concepts/glossary.md +23 -0
  39. package/docs/concepts/initialization-flow.md +148 -0
  40. package/docs/concepts/policy-packs.md +229 -0
  41. package/docs/headless.md +190 -0
  42. package/docs/hooks/use-color-scheme.md +40 -0
  43. package/docs/hooks/use-consent-manager/checking-consent.md +94 -0
  44. package/docs/hooks/use-consent-manager/location-info.md +95 -0
  45. package/docs/hooks/use-consent-manager/overview.md +420 -0
  46. package/docs/hooks/use-consent-manager/setting-consent.md +92 -0
  47. package/docs/hooks/use-draggable.md +57 -0
  48. package/docs/hooks/use-focus-trap.md +41 -0
  49. package/docs/hooks/use-reduced-motion.md +35 -0
  50. package/docs/hooks/use-ssr-status.md +31 -0
  51. package/docs/hooks/use-text-direction.md +49 -0
  52. package/docs/hooks/use-translations.md +118 -0
  53. package/docs/iab/consent-banner.md +94 -0
  54. package/docs/iab/consent-dialog.md +134 -0
  55. package/docs/iab/overview.md +126 -0
  56. package/docs/iab/use-gvl-data.md +20 -0
  57. package/docs/iframe-blocking.md +107 -0
  58. package/docs/integrations/building-integrations.md +405 -0
  59. package/docs/integrations/databuddy.md +203 -0
  60. package/docs/integrations/google-tag-manager.md +153 -0
  61. package/docs/integrations/google-tag.md +122 -0
  62. package/docs/integrations/linkedin-insights.md +109 -0
  63. package/docs/integrations/meta-pixel.md +342 -0
  64. package/docs/integrations/microsoft-uet.md +112 -0
  65. package/docs/integrations/overview.md +105 -0
  66. package/docs/integrations/posthog.md +199 -0
  67. package/docs/integrations/tiktok-pixel.md +113 -0
  68. package/docs/integrations/x-pixel.md +143 -0
  69. package/docs/internationalization.md +197 -0
  70. package/docs/network-blocker.md +178 -0
  71. package/docs/optimization.md +234 -0
  72. package/docs/policy-packs.md +246 -0
  73. package/docs/quickstart.md +161 -0
  74. package/docs/script-loader.md +321 -0
  75. package/docs/server-side.md +176 -0
  76. package/docs/styling/classnames.md +92 -0
  77. package/docs/styling/color-scheme.md +82 -0
  78. package/docs/styling/css-variables.md +92 -0
  79. package/docs/styling/overview.md +456 -0
  80. package/docs/styling/slots.md +127 -0
  81. package/docs/styling/tailwind.md +113 -0
  82. package/docs/styling/tokens.md +216 -0
  83. package/docs/troubleshooting.md +146 -0
  84. package/iab/styles.css +1 -0
  85. package/package.json +36 -15
  86. package/readme.json +4 -0
  87. package/src/iab/styles.css +12 -0
  88. package/src/iab/styles.tw3.css +14 -0
  89. package/src/styles.css +10 -0
  90. package/src/styles.tw3.css +13 -0
  91. package/styles.css +1 -0
  92. package/dist/headless.d.ts.map +0 -1
  93. package/dist/index.d.ts.map +0 -1
  94. package/dist/libs/initial-data.d.ts.map +0 -1
  95. package/dist/types.d.ts +0 -16
  96. package/dist/types.d.ts.map +0 -1
  97. package/dist/version.d.ts +0 -2
  98. package/dist/version.d.ts.map +0 -1
@@ -0,0 +1,73 @@
1
+ ---
2
+ title: Frame
3
+ description: A consent-gated content wrapper - children only mount when the required consent category is granted.
4
+ ---
5
+ `Frame` conditionally renders its children based on consent state. When consent for the specified category is not granted, a placeholder is shown instead. Children are not mounted at all until consent is given, preventing any network requests or script execution.
6
+
7
+ ## Basic Usage
8
+
9
+ ```tsx
10
+ import { Frame } from '@c15t/nextjs';
11
+
12
+ function YouTubeEmbed() {
13
+ return (
14
+ <Frame category="marketing">
15
+ <iframe
16
+ src="https://www.youtube.com/embed/dQw4w9WgXcQ"
17
+ width="560"
18
+ height="315"
19
+ allowFullScreen
20
+ />
21
+ </Frame>
22
+ );
23
+ }
24
+ ```
25
+
26
+ ## Custom Placeholder
27
+
28
+ Replace the default placeholder:
29
+
30
+ ```tsx
31
+ <Frame
32
+ category="experience"
33
+ placeholder={
34
+ <div className="rounded-lg border p-8 text-center">
35
+ <p>This content requires experience cookies.</p>
36
+ <p>Please enable them in your privacy settings.</p>
37
+ </div>
38
+ }
39
+ >
40
+ <InteractiveWidget />
41
+ </Frame>
42
+ ```
43
+
44
+ ## Compound Components
45
+
46
+ Build fully custom placeholder layouts:
47
+
48
+ ```tsx
49
+ <Frame.Root category="marketing">
50
+ <Frame.Title category="marketing" />
51
+ <Frame.Button category="marketing" />
52
+ </Frame.Root>
53
+ ```
54
+
55
+ * `Frame.Root` - Container with default placeholder styling
56
+ * `Frame.Title` - Displays a consent-request message with the category name
57
+ * `Frame.Button` - Button that opens the consent dialog for the specified category
58
+
59
+ ## Automatic Category Registration
60
+
61
+ When `Frame` mounts, it automatically adds its `category` to the active `consentCategories` list. This means you don't need to explicitly list the category in your provider's `consentCategories` option - if a `Frame` component uses it, it will be registered.
62
+
63
+ ## Props
64
+
65
+ ### FrameProps
66
+
67
+ |Property|Type|Description|Default|Required|
68
+ |:--|:--|:--|:--|:--:|
69
+ |children|ReactNode|Content rendered when consent is granted. Children are not mounted until consent is given, preventing unnecessary network requests.|-|✅ Required|
70
+ |category|AllConsentNames|Consent category required to render children.|-|✅ Required|
71
+ |placeholder|ReactNode|A custom placeholder component to display when consent is not met. If not provided, a default placeholder will be displayed.|-|Optional|
72
+ |noStyle|boolean \|undefined|When true, removes all default styling from the component|false|Optional|
73
+ |theme|any|Custom theme to override default styles while maintaining structure and accessibility. Merges with defaults. Ignored when \`noStyle=\{true}\`.|undefined|Optional|
@@ -0,0 +1,175 @@
1
+ ---
2
+ title: Client Modes
3
+ description: Choose how c15t connects to its backend - full hosted integration, offline-only, or bring your own backend.
4
+ ---
5
+ c15t supports three client modes that determine how consent data is stored and synchronized. Choose the mode that matches your infrastructure:
6
+
7
+ * **Hosted mode** - Recommended for production. Backend-backed consent with geolocation, centralized policy resolution, audit history, and offline fallback.
8
+ * **Offline mode** - Browser-only storage with no network requests. Best for local development, demos, static deployments, or controlled fallback scenarios.
9
+ * **Custom mode** - Bring your own backend with custom endpoint handlers
10
+
11
+ > ℹ️ **Info:**
12
+ > 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.
13
+
14
+ <span id="c15t-mode" />
15
+
16
+ ## Hosted Mode (Recommended)
17
+
18
+ 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.
19
+
20
+ > ℹ️ **Info:**
21
+ > mode: 'hosted' is the preferred value. The legacy alias mode: 'c15t' is still supported for backward compatibility.
22
+
23
+ **What happens:**
24
+
25
+ 1. On page load, the client calls `/init` to fetch geolocation, jurisdiction, localized translation strings
26
+ 2. When the user grants or changes consent, it is saved locally before being synced to the backend.
27
+ 3. If the backend is unreachable, it falls back to Offline mode and re-syncs with the backend when it's available
28
+
29
+ **Configuration:**
30
+
31
+ * `backendURL` (required) - API endpoint path
32
+
33
+ **Why it is the default for production:**
34
+
35
+ * The backend stays the source of truth for policy, translations, and jurisdiction logic
36
+ * Consent decisions can be stored beyond the current browser session for audit and support workflows
37
+ * Server-side systems can preload consent-aware behavior instead of waiting for client-only storage
38
+ * If the backend is temporarily unavailable, c15t can fall back locally and re-sync later
39
+
40
+ **Best for:** Production apps that need geolocation-based jurisdiction detection, consent record storage, and compliance audit trails.
41
+
42
+ ```tsx
43
+ import { type ReactNode } from 'react';
44
+ import { ConsentManagerProvider, ConsentBanner } from '@c15t/nextjs';
45
+
46
+ export function ConsentManager({ children }: { children: ReactNode }) {
47
+ return (
48
+ <ConsentManagerProvider
49
+ options={{
50
+ mode: 'hosted',
51
+ backendURL: '/api/c15t',
52
+ }}
53
+ >
54
+ <ConsentBanner />
55
+ {children}
56
+ </ConsentManagerProvider>
57
+ );
58
+ }
59
+ ```
60
+
61
+ ## Offline Mode
62
+
63
+ No network requests. Consent is stored entirely in the browser using localStorage and cookies.
64
+
65
+ **What happens:**
66
+
67
+ 1. Default jurisdiction is GDPR unless manually set via `overrides`
68
+ 2. Consent preferences persist locally only
69
+ 3. No server-side consent records or analytics
70
+
71
+ > ℹ️ **Info:**
72
+ > Important: Offline mode still stores consent locally (cookie + localStorage). It only skips backend storage and sync.
73
+
74
+ ### Consequences of Browser-Only Storage
75
+
76
+ If consent is not stored at all (for example, storage is blocked or frequently cleared):
77
+
78
+ * Users are treated as new visitors and must re-consent repeatedly
79
+ * Preferences are lost across browser resets, private sessions, and device changes
80
+ * You have no reliable audit evidence to prove prior consent choices
81
+ * Support and compliance teams have no centralized visibility into consent history by default
82
+ * Server-side systems cannot apply prior consent decisions before client initialization
83
+
84
+ **Trade-offs:**
85
+
86
+ * No automatic geolocation or jurisdiction detection
87
+ * No consent audit trail
88
+ * No centralized policy or translation updates without shipping frontend changes
89
+ * No cross-device sync
90
+ * No server-side visibility before client initialization
91
+ * Works without any backend infrastructure
92
+
93
+ **Best for:** Local development, Storybook/static demos, resilience fallback, or simpler sites that explicitly accept browser-only consent storage.
94
+
95
+ ```tsx
96
+ import { type ReactNode } from 'react';
97
+ import { ConsentManagerProvider, ConsentBanner } from '@c15t/nextjs';
98
+
99
+ export function ConsentManager({ children }: { children: ReactNode }) {
100
+ return (
101
+ <ConsentManagerProvider
102
+ options={{
103
+ mode: 'offline',
104
+ overrides: {
105
+ country: 'DE', // Override country to trigger GDPR jurisdiction
106
+ },
107
+ }}
108
+ >
109
+ <ConsentBanner />
110
+ {children}
111
+ </ConsentManagerProvider>
112
+ );
113
+ }
114
+ ```
115
+
116
+ ## Custom Mode
117
+
118
+ Bring your own backend. You provide handler functions for each consent endpoint, and c15t calls them instead of making HTTP requests.
119
+
120
+ **What happens:**
121
+
122
+ 1. On page load, the client calls your endpoint handler to fetch geolocation, jurisdiction, localized translation strings
123
+ 2. When the user grants or changes consent, it is saved locally before being synced to the backend.
124
+ 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
125
+
126
+ This lets you integrate c15t with any existing API - your CRM, your own consent database, or a third-party compliance service.
127
+
128
+ **Best for:** Teams with existing consent infrastructure that want c15t's frontend without its backend.
129
+
130
+ ```tsx
131
+ import { type ReactNode } from 'react';
132
+ import { ConsentManagerProvider, ConsentBanner } from '@c15t/nextjs';
133
+
134
+ export function ConsentManager({ children }: { children: ReactNode }) {
135
+ return (
136
+ <ConsentManagerProvider
137
+ options={{
138
+ mode: 'custom',
139
+ endpointHandlers: {
140
+ async init() {
141
+ const res = await fetch('/my-api/consent/init');
142
+ const data = await res.json();
143
+ return { data, response: res, error: null };
144
+ },
145
+ async setConsent(options) {
146
+ const res = await fetch('/my-api/consent', {
147
+ method: 'POST',
148
+ headers: { 'Content-Type': 'application/json' },
149
+ body: JSON.stringify(options?.body),
150
+ });
151
+ return { data: await res.json(), response: res, error: null };
152
+ },
153
+ },
154
+ }}
155
+ >
156
+ <ConsentBanner />
157
+ {children}
158
+ </ConsentManagerProvider>
159
+ );
160
+ }
161
+ ```
162
+
163
+ ## Choosing a Mode
164
+
165
+ |Feature|Hosted|Offline|Custom|
166
+ |--|--|--|--|
167
+ |Geolocation|Automatic|Manual via overrides|Your implementation|
168
+ |Policy source of truth|Backend-managed|Bundled into the frontend|Your implementation|
169
+ |Consent sync|API|Local only|Your implementation|
170
+ |Audit trail|Backend records|Not available|Your implementation|
171
+ |Server-side consent awareness|Supported|Not available|Your implementation|
172
+ |SSR data|Supported|Not available|Your implementation|
173
+ |Analytics|Built-in|Not available|Your implementation|
174
+ |Infrastructure|c15t backend|None|Your backend|
175
+ |Setup effort|Minimal|Zero|Moderate|
@@ -0,0 +1,97 @@
1
+ ---
2
+ title: Consent Categories
3
+ description: How c15t organizes tracking technologies into five consent categories.
4
+ ---
5
+ 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.
6
+
7
+ > ℹ️ **Info:**
8
+ > 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.
9
+
10
+ Configure which categories your app supports in the provider:
11
+
12
+ ```tsx
13
+ import { type ReactNode } from 'react';
14
+ import { ConsentManagerProvider } from '@c15t/nextjs';
15
+
16
+ export function ConsentManager({ children }: { children: ReactNode }) {
17
+ return (
18
+ <ConsentManagerProvider
19
+ options={{
20
+ mode: 'hosted',
21
+ backendURL: '/api/c15t',
22
+ consentCategories: ['necessary', 'measurement', 'marketing'],
23
+ }}
24
+ >
25
+ {children}
26
+ </ConsentManagerProvider>
27
+ );
28
+ }
29
+ ```
30
+
31
+ ## The Five Categories
32
+
33
+ |Category|Default|Toggleable|Description|
34
+ |--|--|--|--|
35
+ |`necessary`|`true`|No|Strictly necessary to operate or deliver the service|
36
+ |`functionality`|`false`|Yes|Basic interactions and functionalities|
37
+ |`experience`|`false`|Yes|Improve quality of user experience|
38
+ |`measurement`|`false`|Yes|Measure traffic and analyze behavior|
39
+ |`marketing`|`false`|Yes|Deliver personalized ads or marketing content|
40
+
41
+ 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.
42
+
43
+ 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).
44
+
45
+ Check if a specific category has consent using the `has()` method:
46
+
47
+ ```tsx
48
+ import { useConsentManager } from '@c15t/nextjs';
49
+
50
+ function AnalyticsLoader() {
51
+ const { has } = useConsentManager();
52
+
53
+ if (has('measurement')) {
54
+ // Safe to load analytics scripts
55
+ }
56
+
57
+ return null;
58
+ }
59
+ ```
60
+
61
+ ## Configuring Categories
62
+
63
+ 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.
64
+
65
+ 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.
66
+
67
+ For example, if you set:
68
+
69
+ ```
70
+ consentCategories: ['necessary', 'measurement', 'marketing']
71
+ ```
72
+
73
+ then only those three categories will show toggles in the consent UI. The `functionality` and `experience` categories will not appear as user-configurable toggles.
74
+
75
+ 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.
76
+
77
+ 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.
78
+
79
+ You can dynamically update which categories are active:
80
+
81
+ ```tsx
82
+ import { useConsentManager } from '@c15t/nextjs';
83
+
84
+ function CategoryManager() {
85
+ const { consentCategories, setConsentCategories } = useConsentManager();
86
+
87
+ const addExperienceCategory = () => {
88
+ setConsentCategories([...consentCategories, 'experience']);
89
+ };
90
+
91
+ return (
92
+ <button onClick={addExperienceCategory}>
93
+ Enable experience features
94
+ </button>
95
+ );
96
+ }
97
+ ```
@@ -0,0 +1,116 @@
1
+ ---
2
+ title: Consent Models
3
+ description: How c15t determines consent behavior based on legal jurisdiction.
4
+ ---
5
+ c15t supports four consent models that control how consent defaults, banner visibility, and category gating behave:
6
+
7
+ |Model|Philosophy|Banner|Categories default to|
8
+ |--|--|--|--|
9
+ |`opt-in`|Explicit consent required|Blocking banner|`false` (except `necessary`)|
10
+ |`opt-out`|Processing allowed by default|Non-blocking notice|`true` (all granted)|
11
+ |`iab`|IAB TCF 2.3 for programmatic ads|TCF banner|Managed by TCF framework|
12
+ |`null`|No regulation detected|No banner|`true` (all auto-granted)|
13
+
14
+ There are two ways c15t determines which model applies:
15
+
16
+ 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).
17
+
18
+ 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.
19
+
20
+ > ℹ️ **Info:**
21
+ > When using policy packs, the consent.model field in each policy directly sets the model — the automatic jurisdiction mapping is bypassed for that request.
22
+
23
+ Read the current consent model from the hook:
24
+
25
+ ```tsx
26
+ 'use client';
27
+
28
+ import { useConsentManager } from '@c15t/nextjs';
29
+
30
+ function ConsentStatus() {
31
+ const { model, policy } = useConsentManager();
32
+
33
+ return (
34
+ <p>
35
+ Current consent model: {model ?? 'detecting...'}
36
+ {policy && ` (from policy: ${policy.id})`}
37
+ </p>
38
+ );
39
+ }
40
+ ```
41
+
42
+ ## The Four Models
43
+
44
+ ### Opt-in
45
+
46
+ 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.
47
+
48
+ 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.
49
+
50
+ ### Opt-out
51
+
52
+ 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.
53
+
54
+ Applies to: California (CCPA), Canada (PIPEDA), Australia.
55
+
56
+ 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.
57
+
58
+ ### IAB
59
+
60
+ 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.
61
+
62
+ 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.
63
+
64
+ ### null
65
+
66
+ Returned when no jurisdiction is detected (`NONE` or `null`). No banner is displayed. On first visit, all categories are auto-granted.
67
+
68
+ ## Jurisdiction Mapping
69
+
70
+ When no policy pack is configured, c15t maps jurisdictions to models automatically:
71
+
72
+ |Jurisdiction Code|Region|Consent Model|
73
+ |--|--|--|
74
+ |`GDPR`|European Union|opt-in|
75
+ |`UK_GDPR`|United Kingdom|opt-in|
76
+ |`CH`|Switzerland|opt-in|
77
+ |`BR`|Brazil (LGPD)|opt-in|
78
+ |`APPI`|Japan|opt-in|
79
+ |`PIPA`|South Korea|opt-in|
80
+ |`PIPEDA`|Canada (excl. Quebec)|opt-out|
81
+ |`QC_LAW25`|Quebec, Canada|opt-in|
82
+ |`CCPA`|California, USA|opt-out|
83
+ |`AU`|Australia|opt-out|
84
+ |`NONE`|No jurisdiction|null|
85
+ |*(unknown)*|Any other|opt-in|
86
+
87
+ **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.
88
+
89
+ > ℹ️ **Info:**
90
+ > 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.
91
+
92
+ Override the detected jurisdiction for testing:
93
+
94
+ ```tsx
95
+ 'use client';
96
+
97
+ import { useConsentManager } from '@c15t/nextjs';
98
+
99
+ function JurisdictionTester() {
100
+ const { setOverrides } = useConsentManager();
101
+
102
+ return (
103
+ <div>
104
+ <button onClick={() => setOverrides({ country: 'DE' })}>
105
+ Test as EU visitor
106
+ </button>
107
+ <button onClick={() => setOverrides({ country: 'US', region: 'CA' })}>
108
+ Test as California visitor
109
+ </button>
110
+ </div>
111
+ );
112
+ }
113
+ ```
114
+
115
+ > ℹ️ **Info:**
116
+ > For full control over which model applies where — plus UI customization, category scoping, and re-prompting — see Policy Packs.
@@ -0,0 +1,122 @@
1
+ ---
2
+ title: Cookie Management
3
+ description: How c15t manages cookies through script, iframe, and network gating
4
+ lastModified: 2026-02-10
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
+ > ℹ️ **Info:**
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
+ Configure reload behavior in the provider:
49
+
50
+ ```tsx
51
+ import { type ReactNode } from 'react';
52
+ import { ConsentManagerProvider } from '@c15t/nextjs';
53
+
54
+ function ConsentManager({ children }: { children: ReactNode }) {
55
+ return (
56
+ <ConsentManagerProvider
57
+ options={{
58
+ mode: 'hosted',
59
+ backendURL: '/api/c15t',
60
+ reloadOnConsentRevoked: true, // default: true
61
+ callbacks: {
62
+ onBeforeConsentRevocationReload: ({ preferences }) => {
63
+ // Run cleanup before the page reloads
64
+ // e.g., flush pending analytics events
65
+ console.log('Reloading due to consent revocation:', preferences);
66
+ },
67
+ },
68
+ }}
69
+ >
70
+ {children}
71
+ </ConsentManagerProvider>
72
+ );
73
+ }
74
+ ```
75
+
76
+ > ℹ️ **Info:**
77
+ > The reload and deferred sync are part of the broader initialization flow. See Initialization Flow for the full sequence.
78
+ >
79
+ > ℹ️ **Info:**
80
+ > Setting reloadOnConsentRevoked: false means previously-loaded scripts will continue running after consent is revoked. Only disable this if you have a specific strategy for handling script cleanup.
81
+
82
+ ## The Revocation Flow
83
+
84
+ When a user revokes consent, the following sequence occurs:
85
+
86
+ **Simplified**
87
+
88
+ 1. **User revokes consent** — e.g. turns off "measurement" in the consent dialog
89
+ 2. **New consent saved** — updated preferences are written to cookies and localStorage
90
+ 3. **Pending sync stored** — the API update is deferred to localStorage (`c15t:pending-consent-sync`)
91
+ 4. **Page reloads** — a fresh execution context ensures revoked scripts never load
92
+ 5. **Fresh init** — c15t reads updated consent; scripts without consent are never loaded
93
+ 6. **Deferred API sync** — the pending consent change is sent to the backend and cleared from localStorage
94
+
95
+ **Sequence Diagram**
96
+
97
+ ```mermaid
98
+ sequenceDiagram
99
+ participant User
100
+ participant UI as Consent UI
101
+ participant Store as Consent Store
102
+ participant Storage as Cookie + localStorage
103
+ participant API as c15t Backend
104
+ participant Browser
105
+
106
+ User->>UI: Revokes "measurement" consent
107
+ UI->>Store: saveConsents({ type: 'custom' })
108
+ Store->>Store: shouldReloadOnConsentChange() → true
109
+ Store->>Storage: Save new consent state
110
+ Store->>Storage: Store PendingConsentSync in localStorage
111
+ Store->>Browser: onBeforeConsentRevocationReload callback
112
+ Store->>Browser: window.location.reload()
113
+ Browser->>Browser: Fresh page load
114
+ Browser->>Storage: Read consent state
115
+ Browser->>Store: Initialize with updated consents
116
+ Note over Store: Scripts without consent are never loaded
117
+ Store->>Storage: Read PendingConsentSync
118
+ Store->>API: Sync consent to backend
119
+ Store->>Storage: Clear PendingConsentSync
120
+ ```
121
+
122
+ **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,23 @@
1
+ ---
2
+ title: Glossary
3
+ description: Key terms used throughout the c15t documentation.
4
+ ---
5
+ ### Core Terms
6
+
7
+ |Term|Definition|
8
+ |--|--|
9
+ |`subjectId`|Client-generated device/browser identifier (`sub_xxx`). Stored in the `c15t` cookie. Created on first consent save.|
10
+ |`externalId`|Your authenticated user's ID (from Clerk, Auth0, etc.), linked via `identifyUser()`. Connects a device to a user account.|
11
+ |`consents`|The **saved** consent state — `Record<string, boolean>` mapping categories to granted/denied. Used for gating scripts, iframes, and network requests.|
12
+ |`selectedConsents`|**Unsaved** toggle state — what the user has toggled in the dialog but hasn't submitted yet. Becomes `consents` after save.|
13
+ |`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).|
14
+ |`model`|Consent regulatory model derived from jurisdiction: `'opt-in'`, `'opt-out'`, `'iab'`, or `null`. See [Consent Models](/docs/frameworks/react/concepts/consent-models).|
15
+
16
+ ### Regulatory Terms
17
+
18
+ |Term|Definition|
19
+ |--|--|
20
+ |`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.|
21
+ |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).|
22
+ |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).|
23
+ |GVL|Global Vendor List — an IAB-maintained registry of ad-tech vendors and their declared purposes, used by the TCF consent flow.|