@c15t/nextjs 2.2.1 → 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 (220) hide show
  1. package/AGENTS.md +102 -142
  2. package/README.md +4 -4
  3. package/dist/api.js +1 -0
  4. package/dist/config.js +1 -0
  5. package/dist/devtools.js +2 -0
  6. package/dist/headers.js +1 -0
  7. package/dist/iab/styles.css +1 -1
  8. package/dist/iab/styles.tw3.css +133 -19
  9. package/dist/index.js +1 -1
  10. package/dist/middleware.js +1 -0
  11. package/dist/node-bridge.js +1 -0
  12. package/dist/pages.js +1 -0
  13. package/dist/proxy.js +1 -0
  14. package/dist/root.js +2 -0
  15. package/dist/server.js +1 -0
  16. package/dist/static.js +1 -0
  17. package/dist/styles.css +1 -1
  18. package/dist/styles.tw3.css +173 -29
  19. package/dist/version.js +1 -1
  20. package/dist-types/api.d.ts +88 -0
  21. package/dist-types/config.d.ts +110 -0
  22. package/dist-types/devtools.d.ts +1 -0
  23. package/dist-types/headers.d.ts +4 -0
  24. package/dist-types/index.d.ts +28 -10
  25. package/dist-types/middleware.d.ts +15 -0
  26. package/dist-types/node-bridge.d.ts +57 -0
  27. package/dist-types/pages.d.ts +88 -0
  28. package/dist-types/proxy.d.ts +34 -0
  29. package/dist-types/root.d.ts +86 -0
  30. package/dist-types/server.d.ts +164 -0
  31. package/dist-types/static.d.ts +42 -0
  32. package/dist-types/types.d.ts +5 -36
  33. package/dist-types/version.d.ts +1 -1
  34. package/docs/README.md +102 -142
  35. package/docs/assets/v3/brand-bar.png +0 -0
  36. package/docs/assets/v3/brand-card.png +0 -0
  37. package/docs/assets/v3/choice-wall.png +0 -0
  38. package/docs/assets/v3/mobile-card.png +0 -0
  39. package/docs/assets/v3/preferences.png +0 -0
  40. package/docs/customization/overview.md +45 -0
  41. package/docs/customization/recipes.md +79 -0
  42. package/docs/customization/slots.md +55 -0
  43. package/docs/customization/tokens.md +76 -0
  44. package/docs/customization/translations.md +49 -0
  45. package/docs/frameworks/next/api-reference/data-fetching.md +416 -0
  46. package/docs/frameworks/next/app-router.md +403 -0
  47. package/docs/frameworks/next/client-side.md +118 -0
  48. package/docs/frameworks/next/components/consent-banner.md +251 -211
  49. package/docs/frameworks/next/components/consent-dialog-link.md +96 -35
  50. package/docs/frameworks/next/components/consent-dialog-trigger.md +74 -149
  51. package/docs/frameworks/next/components/consent-dialog.md +189 -134
  52. package/docs/frameworks/next/components/consent-manager-provider.md +60 -318
  53. package/docs/frameworks/next/components/consent-widget.md +172 -114
  54. package/docs/frameworks/next/components/dev-tools.md +199 -40
  55. package/docs/frameworks/next/components/frame.md +137 -42
  56. package/docs/frameworks/next/concepts/consent-categories.md +24 -89
  57. package/docs/frameworks/next/concepts/policy-presets.md +142 -0
  58. package/docs/frameworks/next/content-security-policy.md +189 -0
  59. package/docs/frameworks/next/data-fetching.md +74 -0
  60. package/docs/frameworks/next/geography-headers.md +251 -0
  61. package/docs/frameworks/next/headless.md +95 -185
  62. package/docs/frameworks/next/hooks/use-consent-manager/overview.md +42 -163
  63. package/docs/frameworks/next/iab/overview.md +37 -107
  64. package/docs/frameworks/next/optimization.md +158 -194
  65. package/docs/frameworks/next/pages-router.md +296 -0
  66. package/docs/frameworks/next/quickstart.md +31 -132
  67. package/docs/frameworks/next/script-loader.md +134 -467
  68. package/docs/frameworks/next/server-side.md +97 -130
  69. package/docs/frameworks/next/static-export.md +164 -0
  70. package/docs/frameworks/next/styling/overview.md +166 -250
  71. package/docs/frameworks/next/troubleshooting.md +134 -144
  72. package/docs/guides/consent-state.md +60 -0
  73. package/docs/guides/data-fetching.md +163 -0
  74. package/docs/guides/deployment-modes.md +63 -0
  75. package/docs/guides/troubleshooting.md +68 -0
  76. package/docs/guides/verify-consent.md +62 -0
  77. package/docs/integrations/adobe-analytics.md +239 -105
  78. package/docs/integrations/ahrefs-analytics.md +238 -104
  79. package/docs/integrations/amplitude.md +219 -157
  80. package/docs/integrations/building-integrations.md +32 -224
  81. package/docs/integrations/clearbit.md +247 -86
  82. package/docs/integrations/cloudflare-web-analytics.md +250 -84
  83. package/docs/integrations/crisp.md +251 -97
  84. package/docs/integrations/databuddy.md +259 -153
  85. package/docs/integrations/fathom-analytics.md +239 -96
  86. package/docs/integrations/google-maps.md +328 -207
  87. package/docs/integrations/google-tag-manager.md +248 -96
  88. package/docs/integrations/google-tag.md +261 -90
  89. package/docs/integrations/heap.md +222 -149
  90. package/docs/integrations/hightouch.md +225 -131
  91. package/docs/integrations/hotjar.md +239 -90
  92. package/docs/integrations/intercom.md +239 -98
  93. package/docs/integrations/linkedin-insights.md +243 -113
  94. package/docs/integrations/logrocket.md +241 -123
  95. package/docs/integrations/matomo-analytics.md +256 -111
  96. package/docs/integrations/meta-pixel.md +197 -324
  97. package/docs/integrations/microsoft-clarity.md +233 -114
  98. package/docs/integrations/microsoft-uet.md +245 -110
  99. package/docs/integrations/mixpanel-analytics.md +252 -87
  100. package/docs/integrations/openai-pixel.md +441 -0
  101. package/docs/integrations/overview.md +95 -133
  102. package/docs/integrations/pirsch.md +249 -96
  103. package/docs/integrations/plausible-analytics.md +241 -100
  104. package/docs/integrations/posthog.md +353 -214
  105. package/docs/integrations/promptwatch.md +251 -81
  106. package/docs/integrations/reddit-pixel.md +226 -173
  107. package/docs/integrations/rudderstack.md +244 -187
  108. package/docs/integrations/rybbit-analytics.md +244 -91
  109. package/docs/integrations/segment.md +238 -92
  110. package/docs/integrations/snapchat-pixel.md +240 -110
  111. package/docs/integrations/tiktok-pixel.md +249 -81
  112. package/docs/integrations/umami-analytics.md +242 -95
  113. package/docs/integrations/vercel-analytics.md +242 -90
  114. package/docs/integrations/x-pixel.md +238 -104
  115. package/docs/integrations/youtube.md +354 -142
  116. package/docs/upgrade-v3.md +334 -0
  117. package/iab/styles.css +1 -1
  118. package/iab/styles.tw3.css +1 -1
  119. package/package.json +106 -65
  120. package/readme.json +3 -3
  121. package/src/iab/styles.css +1 -1
  122. package/src/iab/styles.tw3.css +1 -1
  123. package/src/styles.css +1 -1
  124. package/src/styles.tw3.css +1 -1
  125. package/styles.css +1 -1
  126. package/styles.tw3.css +1 -1
  127. package/client/components/consent-dialog-link.js +0 -3
  128. package/client/components/integrations.js +0 -3
  129. package/dist/components/integrations/index.cjs +0 -1
  130. package/dist/components/integrations/index.js +0 -1
  131. package/dist/headless.cjs +0 -1
  132. package/dist/index.cjs +0 -1
  133. package/dist/libs/browser-initial-data.cjs +0 -1
  134. package/dist/libs/browser-initial-data.js +0 -1
  135. package/dist/libs/initial-data.cjs +0 -1
  136. package/dist/libs/initial-data.js +0 -1
  137. package/dist/types.cjs +0 -1
  138. package/dist/version.cjs +0 -1
  139. package/dist-types/components/integrations/index.d.ts +0 -1
  140. package/dist-types/libs/browser-initial-data.d.ts +0 -9
  141. package/dist-types/libs/initial-data.d.ts +0 -33
  142. package/docs/frameworks/next/building-headless-components.md +0 -379
  143. package/docs/frameworks/next/callbacks.md +0 -186
  144. package/docs/frameworks/next/concepts/client-modes.md +0 -177
  145. package/docs/frameworks/next/concepts/consent-models.md +0 -117
  146. package/docs/frameworks/next/concepts/cookie-management.md +0 -122
  147. package/docs/frameworks/next/concepts/glossary.md +0 -24
  148. package/docs/frameworks/next/concepts/initialization-flow.md +0 -149
  149. package/docs/frameworks/next/concepts/policy-packs.md +0 -230
  150. package/docs/frameworks/next/hooks/use-color-scheme.md +0 -41
  151. package/docs/frameworks/next/hooks/use-consent-manager/checking-consent.md +0 -96
  152. package/docs/frameworks/next/hooks/use-consent-manager/location-info.md +0 -97
  153. package/docs/frameworks/next/hooks/use-consent-manager/setting-consent.md +0 -94
  154. package/docs/frameworks/next/hooks/use-draggable.md +0 -59
  155. package/docs/frameworks/next/hooks/use-focus-trap.md +0 -42
  156. package/docs/frameworks/next/hooks/use-reduced-motion.md +0 -37
  157. package/docs/frameworks/next/hooks/use-ssr-status.md +0 -32
  158. package/docs/frameworks/next/hooks/use-text-direction.md +0 -50
  159. package/docs/frameworks/next/hooks/use-translations.md +0 -55
  160. package/docs/frameworks/next/iab/consent-banner.md +0 -91
  161. package/docs/frameworks/next/iab/consent-dialog.md +0 -129
  162. package/docs/frameworks/next/iab/use-gvl-data.md +0 -21
  163. package/docs/frameworks/next/iframe-blocking.md +0 -106
  164. package/docs/frameworks/next/internationalization.md +0 -207
  165. package/docs/frameworks/next/network-blocker.md +0 -140
  166. package/docs/frameworks/next/policy-packs.md +0 -248
  167. package/docs/frameworks/next/styling/classnames.md +0 -94
  168. package/docs/frameworks/next/styling/color-scheme.md +0 -84
  169. package/docs/frameworks/next/styling/css-variables.md +0 -53
  170. package/docs/frameworks/next/styling/slots.md +0 -94
  171. package/docs/frameworks/next/styling/tailwind.md +0 -137
  172. package/docs/frameworks/next/styling/tokens.md +0 -156
  173. package/docs/shared/concepts/client-modes.md +0 -103
  174. package/docs/shared/concepts/consent-categories.md +0 -41
  175. package/docs/shared/concepts/consent-models.md +0 -72
  176. package/docs/shared/concepts/cookie-management.md +0 -88
  177. package/docs/shared/concepts/glossary.md +0 -24
  178. package/docs/shared/concepts/initialization-flow.md +0 -105
  179. package/docs/shared/concepts/policy-packs.md +0 -225
  180. package/docs/shared/react/components/consent-banner.md +0 -242
  181. package/docs/shared/react/components/consent-dialog-link.md +0 -45
  182. package/docs/shared/react/components/consent-dialog-trigger.md +0 -185
  183. package/docs/shared/react/components/consent-dialog.md +0 -119
  184. package/docs/shared/react/components/consent-manager-provider.md +0 -225
  185. package/docs/shared/react/components/consent-widget.md +0 -121
  186. package/docs/shared/react/components/dev-tools.md +0 -81
  187. package/docs/shared/react/components/frame.md +0 -52
  188. package/docs/shared/react/guides/building-headless-components.md +0 -110
  189. package/docs/shared/react/guides/callbacks.md +0 -89
  190. package/docs/shared/react/guides/headless.md +0 -31
  191. package/docs/shared/react/guides/iframe-blocking.md +0 -65
  192. package/docs/shared/react/guides/internationalization.md +0 -123
  193. package/docs/shared/react/guides/network-blocker.md +0 -72
  194. package/docs/shared/react/guides/optimization.md +0 -44
  195. package/docs/shared/react/guides/policy-packs.md +0 -173
  196. package/docs/shared/react/guides/script-loader.md +0 -311
  197. package/docs/shared/react/hooks/use-color-scheme.md +0 -31
  198. package/docs/shared/react/hooks/use-consent-manager/checking-consent.md +0 -95
  199. package/docs/shared/react/hooks/use-consent-manager/location-info.md +0 -96
  200. package/docs/shared/react/hooks/use-consent-manager/overview.md +0 -74
  201. package/docs/shared/react/hooks/use-consent-manager/setting-consent.md +0 -93
  202. package/docs/shared/react/hooks/use-draggable.md +0 -30
  203. package/docs/shared/react/hooks/use-focus-trap.md +0 -20
  204. package/docs/shared/react/hooks/use-reduced-motion.md +0 -33
  205. package/docs/shared/react/hooks/use-ssr-status.md +0 -16
  206. package/docs/shared/react/hooks/use-text-direction.md +0 -38
  207. package/docs/shared/react/hooks/use-translations.md +0 -15
  208. package/docs/shared/react/iab/consent-banner.md +0 -60
  209. package/docs/shared/react/iab/consent-dialog.md +0 -76
  210. package/docs/shared/react/iab/overview.md +0 -80
  211. package/docs/shared/react/iab/use-gvl-data.md +0 -21
  212. package/docs/shared/react/styling/classnames.md +0 -93
  213. package/docs/shared/react/styling/color-scheme.md +0 -35
  214. package/docs/shared/react/styling/css-variables.md +0 -53
  215. package/docs/shared/react/styling/overview.md +0 -261
  216. package/docs/shared/react/styling/slots.md +0 -93
  217. package/docs/shared/react/styling/stylesheet-entrypoint.md +0 -8
  218. package/docs/shared/react/styling/tailwind.md +0 -88
  219. package/docs/shared/react/styling/tokens.md +0 -155
  220. package/docs/shared/troubleshooting.md +0 -82
@@ -1,32 +0,0 @@
1
- ---
2
- title: useSSRStatus
3
- description: Check whether server-side rendered consent data was used during initialization.
4
- group: frameworks
5
- ---
6
- `useSSRStatus()` returns information about whether SSR data was used for consent manager initialization. This is primarily useful for debugging SSR data flow in Next.js or other server-rendering frameworks.
7
-
8
- ```tsx
9
- import { useSSRStatus } from '@c15t/nextjs';
10
-
11
- function DebugSSR() {
12
- const { ssrDataUsed, ssrSkippedReason } = useSSRStatus();
13
-
14
- if (ssrDataUsed) {
15
- return <span>Consent initialized from SSR data</span>;
16
- }
17
-
18
- return <span>SSR skipped: {ssrSkippedReason ?? 'unknown'}</span>;
19
- }
20
- ```
21
-
22
- ## Return Value
23
-
24
- |Property|Value|
25
- |:--|:--|
26
- |Type Name|\`SSRStatus\`|
27
- |Source Path|\`./packages/react/src/hooks/use-ssr-status.ts\`|
28
-
29
- \*ExtractedTypeTable: Could not extract "SSRStatus" from "./packages/react/src/hooks/use-ssr-status.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
30
-
31
- > ℹ️ **Info:**
32
- > Must be used within a ConsentManagerProvider. Throws if used outside the provider context.
@@ -1,50 +0,0 @@
1
- ---
2
- title: useTextDirection
3
- description: Manage RTL/LTR text direction based on the active language for consent UI.
4
- group: frameworks
5
- ---
6
- `useTextDirection()` determines the correct text direction (`'ltr'` or `'rtl'`) based on the provided language and sets it on the document. It wraps the `@c15t/ui` text direction utilities as a React hook.
7
-
8
- This is used internally by IAB components but is available for custom UI that needs to handle bidirectional text.
9
-
10
- ```tsx
11
- import { useTextDirection } from '@c15t/react/hooks';
12
-
13
- function CustomConsentUI({ language }: { language: string }) {
14
- const direction = useTextDirection(language);
15
-
16
- return (
17
- <div dir={direction}>
18
- {/* Content renders correctly for RTL languages like Arabic and Hebrew */}
19
- </div>
20
- );
21
- }
22
- ```
23
-
24
- ## Parameters
25
-
26
- |Parameter|Type|Default|Description|
27
- |--|--|--|--|
28
- |`language`|`string \|undefined`|—|BCP 47 language tag (e.g. `'en'`, `'ar'`, `'he'`)|
29
-
30
- ## Return Value
31
-
32
- |Type|Description|
33
- |--|--|
34
- |`'ltr' \|'rtl'`|The text direction for the given language|
35
-
36
- ## RTL Languages
37
-
38
- The hook recognizes standard RTL languages including Arabic (`ar`), Hebrew (`he`), Persian (`fa`), and Urdu (`ur`), among others.
39
-
40
- ```tsx
41
- import { useConsentManager } from '@c15t/nextjs';
42
- import { useTextDirection } from '@c15t/react/hooks';
43
-
44
- function BiDirectionalBanner() {
45
- const { translationConfig } = useConsentManager();
46
- const dir = useTextDirection(translationConfig.defaultLanguage);
47
-
48
- return <div dir={dir}>...</div>;
49
- }
50
- ```
@@ -1,55 +0,0 @@
1
- ---
2
- title: useTranslations
3
- description: Access the current language's translations for building custom consent UI.
4
- group: frameworks
5
- ---
6
- `useTranslations()` returns the `Translations` object for the currently active language. Use it when building custom consent UI that needs translated text.
7
-
8
- ```tsx
9
- import { useTranslations } from '@c15t/nextjs';
10
-
11
- function CustomBanner() {
12
- const translations = useTranslations();
13
-
14
- return (
15
- <div>
16
- <h2>{translations.cookieBanner.title}</h2>
17
- <p>{translations.cookieBanner.description}</p>
18
- <button>{translations.common.acceptAll}</button>
19
- <button>{translations.common.rejectAll}</button>
20
- </div>
21
- );
22
- }
23
- ```
24
-
25
- ## Translation Sections
26
-
27
- The returned `Translations` object has these sections:
28
-
29
- |Property|Value|
30
- |:--|:--|
31
- |Type Name|\`Translations\`|
32
- |Source Path|\`./packages/translations/src/types.ts\`|
33
-
34
- \*ExtractedTypeTable: Could not extract "Translations" from "./packages/translations/src/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
35
-
36
- ## With setLanguage
37
-
38
- Translations update automatically when the language changes:
39
-
40
- ```tsx
41
- import { useConsentManager, useTranslations } from '@c15t/nextjs';
42
-
43
- function LocalizedConsent() {
44
- const { setLanguage } = useConsentManager();
45
- const translations = useTranslations();
46
-
47
- return (
48
- <div>
49
- <p>{translations.cookieBanner.description}</p>
50
- <button onClick={() => setLanguage('de')}>Deutsch</button>
51
- <button onClick={() => setLanguage('fr')}>Français</button>
52
- </div>
53
- );
54
- }
55
- ```
@@ -1,91 +0,0 @@
1
- ---
2
- title: IABConsentBanner
3
- description: An IAB TCF 2.3 compliant consent banner that displays partner
4
- count, purpose summaries, and legitimate interest notices.
5
- group: frameworks
6
- ---
7
- > ℹ️ **Info:**
8
- > c15t's IAB TCF support can be used in production. Use Inth for a hosted, IAB TCF-certified CMP setup with a managed CMP ID, or register your own CMP with IAB Europe and configure your own CMP ID.
9
-
10
- `IABConsentBanner` is a pre-built consent banner that follows the [IAB Transparency & Consent Framework (TCF) 2.3](https://iabeurope.eu/tcf-2-0/) specification. It renders when the consent model is set to `'iab'` and includes required disclosures like partner count, purpose summaries, and legitimate interest notices.
11
-
12
- Use this component instead of `ConsentBanner` when you need IAB TCF compliance for programmatic advertising in EU jurisdictions.
13
-
14
- ## When to Use
15
-
16
- * Your site participates in the IAB TCF ecosystem (ad exchanges, SSPs, DSPs)
17
- * You need to disclose vendor partnerships and data processing purposes per IAB requirements
18
- * The detected jurisdiction requires IAB TCF compliance (typically EU/EEA)
19
-
20
- ## Basic Usage
21
-
22
- ```tsx
23
- import { type ReactNode } from 'react';
24
- import { iab } from '@c15t/iab';
25
- import { ConsentManagerProvider } from '@c15t/nextjs';
26
- import { IABConsentBanner, IABConsentDialog } from '@c15t/react/iab';
27
-
28
- export default function ConsentManager({ children }: { children: ReactNode }) {
29
- return (
30
- <ConsentManagerProvider
31
- options={{
32
- mode: 'hosted',
33
- backendURL: '/api/c15t',
34
- iab: iab({
35
- vendors: [1, 2, 10, 25],
36
- // cmpId is automatically provided by the backend when using Inth.
37
- // Only set this if you have your own CMP registration.
38
- // cmpId: 123,
39
- }),
40
- }}
41
- >
42
- <IABConsentBanner />
43
- <IABConsentDialog />
44
- {children}
45
- </ConsentManagerProvider>
46
- );
47
- }
48
- ```
49
-
50
- > ℹ️ **Info:**
51
- > The banner only renders when IAB mode is enabled and the GVL (Global Vendor List) has been loaded. If iab.enabled is false or the server does not return GVL data, nothing is rendered.
52
-
53
- ## Banner Content
54
-
55
- The IAB banner automatically displays:
56
-
57
- * **Title** — Heading text from IAB translations
58
- * **Description** — Includes the partner count (e.g., "We and our \{partnerCount} partners...")
59
- * **Partners link** — Clickable link that opens the vendor tab in the preference center
60
- * **Purpose/stack list** — Up to 5 purpose/stack names summarizing data usage, with an "and X more" overflow
61
- * **Legitimate interest notice** — Required IAB disclosure about legitimate interest processing
62
- * **Scope notice** — Service-specific scope disclosure
63
-
64
- ## Buttons
65
-
66
- The banner includes three action buttons:
67
-
68
- |Button|Action|
69
- |--|--|
70
- |**Reject All**|Rejects all IAB purposes and closes the banner|
71
- |**Accept All**|Accepts all IAB purposes and closes the banner|
72
- |**Customize**|Opens the IABConsentDialog purposes tab|
73
-
74
- ### Primary Button
75
-
76
- Highlight a specific button as the primary action:
77
-
78
- ```tsx
79
- <IABConsentBanner primaryButton="accept" />
80
- ```
81
-
82
- Options: `'reject'`, `'accept'`, `'customize'` (default: `'customize'`)
83
-
84
- ## Props
85
-
86
- |Property|Value|
87
- |:--|:--|
88
- |Type Name|\`IABConsentBannerProps\`|
89
- |Source Path|\`./packages/react/src/components/iab-consent-banner/iab-consent-banner.tsx\`|
90
-
91
- \*ExtractedTypeTable: Could not extract "IABConsentBannerProps" from "./packages/react/src/components/iab-consent-banner/iab-consent-banner.tsx" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
@@ -1,129 +0,0 @@
1
- ---
2
- title: IABConsentDialog
3
- description: An IAB TCF 2.3 compliant preference center with tabbed purpose and
4
- vendor management.
5
- group: frameworks
6
- ---
7
- > ℹ️ **Info:**
8
- > c15t's IAB TCF support can be used in production. Use Inth for a hosted, IAB TCF-certified CMP setup with a managed CMP ID, or register your own CMP with IAB Europe and configure your own CMP ID.
9
-
10
- `IABConsentDialog` is an IAB TCF 2.3 compliant consent dialog that provides a tabbed interface for managing purpose consent and vendor preferences. It includes purpose grouping via stacks, individual purpose/vendor toggles, special purpose and feature disclosures, and legitimate interest handling.
11
-
12
- ## Basic Usage
13
-
14
- Pair it with `IABConsentBanner` inside the provider:
15
-
16
- ```tsx
17
- import { type ReactNode } from 'react';
18
- import { iab } from '@c15t/iab';
19
- import { ConsentManagerProvider } from '@c15t/nextjs';
20
- import { IABConsentBanner, IABConsentDialog } from '@c15t/react/iab';
21
-
22
- export default function ConsentManager({ children }: { children: ReactNode }) {
23
- return (
24
- <ConsentManagerProvider
25
- options={{
26
- mode: 'hosted',
27
- backendURL: '/api/c15t',
28
- iab: iab({
29
- vendors: [1, 2, 10, 25],
30
- // cmpId is automatically provided by the backend when using Inth.
31
- // Only set this if you have your own CMP registration.
32
- // cmpId: 123,
33
- }),
34
- }}
35
- >
36
- <IABConsentBanner />
37
- <IABConsentDialog />
38
- {children}
39
- </ConsentManagerProvider>
40
- );
41
- }
42
- ```
43
-
44
- ## Tabs
45
-
46
- The dialog has two tabs:
47
-
48
- ### Purposes Tab
49
-
50
- Displays all IAB purposes grouped into:
51
-
52
- * **Standalone purposes** — Purpose 1 (Store and/or access information on a device) is always shown standalone per IAB TCF spec
53
- * **Stacks** — Groups of related purposes determined by the GVL. Each stack is expandable to show individual purpose toggles
54
- * **Special features** — Opt-in features like precise geolocation
55
- * **Essential functions** — Special purposes and features that are locked (no user toggle) because they're required for basic operation
56
-
57
- Each purpose shows:
58
-
59
- * Name and description
60
- * Number of vendors using this purpose
61
- * Consent toggle (or lock icon for essential functions)
62
- * Legitimate interest toggle where applicable
63
- * Expandable vendor list
64
-
65
- ### Vendors Tab
66
-
67
- Displays all vendors from the GVL plus any custom vendors:
68
-
69
- * Search and filter vendors
70
- * Per-vendor consent and legitimate interest toggles
71
- * Vendor details: privacy policy link, cookie usage, data retention
72
- * Purpose and feature associations
73
-
74
- ## Controlled State
75
-
76
- By default, the dialog follows `activeUI === 'dialog'` from the consent store. Use `open` for manual control:
77
-
78
- ```tsx
79
- import { useState } from 'react';
80
- import { IABConsentDialog } from '@c15t/react/iab';
81
-
82
- function SettingsPage() {
83
- const [open, setOpen] = useState(false);
84
-
85
- return (
86
- <>
87
- <button onClick={() => setOpen(true)}>TCF Preferences</button>
88
- <IABConsentDialog open={open} />
89
- </>
90
- );
91
- }
92
- ```
93
-
94
- ## Floating Trigger
95
-
96
- Add a floating button so users can re-open the dialog after dismissing the banner. IAB TCF requires the preference center to be easily resurfaceable:
97
-
98
- ```tsx
99
- <IABConsentDialog showTrigger />
100
-
101
- {/* Custom trigger options */}
102
- <IABConsentDialog
103
- showTrigger={{
104
- icon: 'settings',
105
- defaultPosition: 'bottom-left',
106
- showWhen: 'after-consent',
107
- size: 'sm',
108
- }}
109
- />
110
- ```
111
-
112
- ## Footer Actions
113
-
114
- The dialog footer provides three buttons:
115
-
116
- |Button|Action|
117
- |--|--|
118
- |**Reject All**|Rejects all purposes and vendors, closes dialog and banner|
119
- |**Accept All**|Accepts all purposes and vendors, closes dialog and banner|
120
- |**Save Settings**|Saves current selections, closes dialog and banner|
121
-
122
- ## Props
123
-
124
- |Property|Value|
125
- |:--|:--|
126
- |Type Name|\`IABConsentDialogProps\`|
127
- |Source Path|\`./packages/react/src/components/iab-consent-dialog/iab-consent-dialog.tsx\`|
128
-
129
- \*ExtractedTypeTable: Could not extract "IABConsentDialogProps" from "./packages/react/src/components/iab-consent-dialog/iab-consent-dialog.tsx" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
@@ -1,21 +0,0 @@
1
- ---
2
- title: useGVLData (Internal)
3
- description: Status note for the internal GVL hook used by the built-in IAB dialog.
4
- group: frameworks
5
- ---
6
- > ⚠️ **Warning:**
7
- > c15t's IAB TCF support can be used in production through Inth or with your own registered CMP ID. useGVLData() is different: it remains an internal hook and is not part of the supported public API.
8
-
9
- `useGVLData()` currently powers the built-in `IABConsentDialog`, but it is **not part of the public package surface**.
10
-
11
- Older docs showed it as a public hook. That is no longer accurate.
12
-
13
- If you need supported customization points today:
14
-
15
- * Use `IABConsentBanner` and `IABConsentDialog` from `@c15t/react/iab` for the supported prebuilt UI
16
- * Use `useHeadlessIABConsentUI()` from `@c15t/react/iab` when you need lower-level control over banner/dialog state and actions
17
-
18
- > ⚠️ **Warning:**
19
- > Until useGVLData() is exported as public API, avoid importing it from deep internal paths. Those paths are not covered by semver guarantees and can change without notice.
20
-
21
- When a public GVL-focused hook becomes part of the supported API, this page should document that public surface instead of the internal dialog hook.
@@ -1,106 +0,0 @@
1
- ---
2
- title: Iframe Blocking
3
- description: Block embedded content (YouTube, social widgets, maps) until users
4
- grant consent for the appropriate category.
5
- group: frameworks
6
- ---
7
- Embedded iframes from third parties (YouTube, Google Maps, social media widgets) can set cookies and track users without their consent. c15t provides two approaches to gate iframes behind consent:
8
-
9
- 1. **`<Frame>` component** - A React component that conditionally renders children based on consent
10
- 2. **HTML `data-category` attribute** - For raw `<iframe>` elements outside of React
11
-
12
- ## Frame Component
13
-
14
- The `<Frame>` component wraps content that requires consent. Children are only mounted when the specified category has consent. When consent is not granted, a placeholder is shown instead.
15
-
16
- ```tsx
17
- import { Frame } from '@c15t/nextjs';
18
-
19
- function YouTubeEmbed() {
20
- return (
21
- <Frame category="marketing">
22
- <iframe
23
- src="https://www.youtube.com/embed/dQw4w9WgXcQ"
24
- width="560"
25
- height="315"
26
- allowFullScreen
27
- />
28
- </Frame>
29
- );
30
- }
31
- ```
32
-
33
- ### Custom Placeholder
34
-
35
- Replace the default placeholder with your own UI:
36
-
37
- ```tsx
38
- <Frame
39
- category="marketing"
40
- placeholder={
41
- <div className="flex items-center justify-center h-64 bg-gray-100 rounded">
42
- <p>Enable marketing cookies to watch this video.</p>
43
- </div>
44
- }
45
- >
46
- <iframe src="https://www.youtube.com/embed/..." />
47
- </Frame>
48
- ```
49
-
50
- ### Compound Components
51
-
52
- Build custom placeholder layouts using compound components:
53
-
54
- ```tsx
55
- <Frame.Root category="marketing">
56
- <Frame.Title category="marketing" />
57
- <Frame.Button category="marketing" />
58
- </Frame.Root>
59
- ```
60
-
61
- ## HTML Attribute Approach
62
-
63
- For iframes outside of React (e.g., CMS content, server-rendered HTML), add `data-category` and use `data-src` instead of `src`:
64
-
65
- ```html
66
- <iframe
67
- data-src="https://www.youtube.com/embed/dQw4w9WgXcQ"
68
- data-category="marketing"
69
- width="560"
70
- height="315"
71
- ></iframe>
72
- ```
73
-
74
- When consent for the specified category is granted, c15t automatically swaps `data-src` to `src`, loading the iframe. When consent is revoked, `src` is moved back to `data-src`.
75
-
76
- ### Dynamic Iframes
77
-
78
- c15t uses a `MutationObserver` to watch for dynamically added iframes. Any iframe with `data-category` added to the DOM after initialization is automatically processed.
79
-
80
- ## Initializing the Iframe Blocker
81
-
82
- The iframe blocker for HTML attributes needs to be initialized separately from the Frame component:
83
-
84
- ```tsx
85
- import { useConsentManager } from '@c15t/nextjs';
86
- import { useEffect } from 'react';
87
-
88
- function IframeBlockerInit() {
89
- const { initializeIframeBlocker } = useConsentManager();
90
-
91
- useEffect(() => {
92
- initializeIframeBlocker();
93
- }, [initializeIframeBlocker]);
94
-
95
- return null;
96
- }
97
- ```
98
-
99
- ## API Reference
100
-
101
- |Property|Value|
102
- |:--|:--|
103
- |Type Name|\`FrameProps\`|
104
- |Source Path|\`./packages/react/src/components/frame/types.ts\`|
105
-
106
- \*ExtractedTypeTable: Could not extract "FrameProps" from "./packages/react/src/components/frame/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
@@ -1,207 +0,0 @@
1
- ---
2
- title: Internationalization
3
- description: Translate consent UI into 30+ languages with built-in translations,
4
- custom overrides, and automatic browser language detection.
5
- group: frameworks
6
- ---
7
- c15t ships with built-in translations for 30+ languages via the `@c15t/translations` package. Language detection happens automatically based on the browser's language preference, and you can override or extend translations for any language.
8
-
9
- In c15t v2, the preferred config shape is `i18n` with `locale`, `detectBrowserLanguage`, and `messages`.
10
-
11
- There are two ways c15t can load translations: client-side or server-side.
12
-
13
- |Server-side|Client-side|
14
- |--|--|
15
- |The best way to reduce bundle size and improve performance. We can detect the user's language based on the browser's language settings, allowing for the most accurate translations. By default, when using a [inth.com](https://inth.com) hosted instance, [these languages](https://github.com/c15t/c15t/tree/main/packages/translations/src/translations) are supported.|Bundled with the application allowing for multiple languages to be supported without the need for a backend. The more translations you have, the larger the bundle size will be, which may impact the performance of your application.|
16
-
17
- ## Basic Configuration
18
-
19
- Pass custom translations via the `i18n` option:
20
-
21
- ```tsx
22
- import { type ReactNode } from 'react';
23
- import { ConsentManagerProvider } from '@c15t/nextjs';
24
-
25
- export default function ConsentManager({ children }: { children: ReactNode }) {
26
- return (
27
- <ConsentManagerProvider
28
- options={{
29
- mode: 'hosted',
30
- backendURL: '/api/c15t',
31
- i18n: {
32
- locale: 'en',
33
- messages: {
34
- de: {
35
- cookieBanner: {
36
- title: 'Datenschutzeinstellungen',
37
- description: 'Wir verwenden Cookies, um Ihnen das beste Erlebnis zu bieten.',
38
- },
39
- common: {
40
- acceptAll: 'Alle akzeptieren',
41
- rejectAll: 'Alle ablehnen',
42
- customize: 'Anpassen',
43
- save: 'Speichern',
44
- },
45
- },
46
- },
47
- },
48
- }}
49
- >
50
- {children}
51
- </ConsentManagerProvider>
52
- );
53
- }
54
- ```
55
-
56
- Custom translations are deep-merged with built-in defaults - you only need to override the keys you want to change.
57
-
58
- ## Translation Package Imports
59
-
60
- Use the import path that matches your use case:
61
-
62
- * `@c15t/translations`: types, utilities, and `enTranslations` only (smallest client bundle)
63
- * `@c15t/translations/en`: English-only translation object
64
- * `@c15t/translations/all`: full `baseTranslations` map for all bundled locales
65
-
66
- If you bundle translations client-side and need multiple languages, import from `@c15t/translations/all` explicitly:
67
-
68
- ```tsx
69
- import { baseTranslations } from '@c15t/translations/all';
70
-
71
- const translations = {
72
- en: baseTranslations.en,
73
- de: baseTranslations.de,
74
- fr: baseTranslations.fr,
75
- };
76
- ```
77
-
78
- ## Translation Sections
79
-
80
- The `Translations` object is organized into sections:
81
-
82
- |Section|Controls|
83
- |--|--|
84
- |`common`|Shared button labels: acceptAll, rejectAll, customize, save|
85
- |`cookieBanner`|Banner title and description|
86
- |`consentManagerDialog`|Dialog title and description|
87
- |`consentTypes`|Per-category title and description (keyed by AllConsentNames)|
88
- |`frame`|Frame placeholder title, button, loading, and error text (title and button support `{category}`)|
89
- |`legalLinks`|Privacy policy, cookie policy, terms of service link text|
90
- |`iab`|IAB TCF banner, preference center, vendor list translations|
91
-
92
- ## Reading Translations
93
-
94
- Use the `useTranslations()` hook to access the current language's translations:
95
-
96
- ```tsx
97
- import { useTranslations } from '@c15t/nextjs';
98
-
99
- function CustomBanner() {
100
- const translations = useTranslations();
101
-
102
- return (
103
- <div>
104
- <h2>{translations.cookieBanner.title}</h2>
105
- <p>{translations.cookieBanner.description}</p>
106
- </div>
107
- );
108
- }
109
- ```
110
-
111
- ## Changing Language
112
-
113
- Switch the active language at runtime with `setLanguage()`:
114
-
115
- ```tsx
116
- import { useConsentManager } from '@c15t/nextjs';
117
-
118
- function LanguageSwitcher() {
119
- const { setLanguage } = useConsentManager();
120
-
121
- return (
122
- <select onChange={(e) => setLanguage(e.target.value)}>
123
- <option value="en">English</option>
124
- <option value="de">Deutsch</option>
125
- <option value="fr">Fran&ccedil;ais</option>
126
- <option value="es">Espa&ntilde;ol</option>
127
- </select>
128
- );
129
- }
130
- ```
131
-
132
- `setLanguage()` re-fetches the consent banner to get server-resolved translations for the new language.
133
-
134
- ## Automatic Language Detection
135
-
136
- By default, c15t detects the browser's language (`navigator.language`) and selects the closest matching translation. If custom `messages` are configured, fallback stays within your configured languages before using `locale` (or `'en'`) as the preferred fallback language.
137
-
138
- When backend policy packs use `i18n.messageProfile`, the active language pool comes only from that resolved profile.
139
-
140
- Example: if your Europe profile defines `en`, `fr`, and `de`, and your default profile defines `en`, `es`, and `pt`, a Europe visitor can resolve to `en`, `fr`, or `de`, but not `es`, `pt`, or `zh`.
141
-
142
- Use profile-local `fallbackLanguage` inside backend `i18n.messages` to choose which configured language a policy profile should fall back to when the browser asks for an unsupported locale.
143
-
144
- Disable auto-detection to always use `locale`:
145
-
146
- ```tsx
147
- i18n: {
148
- locale: 'de',
149
- detectBrowserLanguage: false,
150
- messages: { ... },
151
- }
152
- ```
153
-
154
- If you need a policy to always use one specific language regardless of browser preference, set `policy.i18n.language` on the backend policy pack.
155
-
156
- ## Custom Consent Type Labels
157
-
158
- Override the title and description for individual consent categories. Frame
159
- placeholders use that title anywhere their message contains `{category}`, so
160
- the title and action stay consistent:
161
-
162
- ```tsx
163
- i18n: {
164
- messages: {
165
- en: {
166
- consentTypes: {
167
- measurement: {
168
- title: 'Analytics & Performance',
169
- description: 'Help us understand how visitors interact with our site.',
170
- },
171
- marketing: {
172
- title: 'Advertising',
173
- description: 'Used to deliver relevant ads and measure campaign effectiveness.',
174
- },
175
- },
176
- frame: {
177
- title: 'Allow {category} consent to view this content.',
178
- actionButton: 'Enable {category} consent',
179
- loading: 'Loading content…',
180
- error: 'This content could not be loaded.',
181
- },
182
- },
183
- },
184
- }
185
- ```
186
-
187
- ## Legacy `translations` Compatibility
188
-
189
- The legacy syntax is still supported in 2.0 for RC compatibility:
190
-
191
- ```tsx
192
- // Legacy (still supported)
193
- translations: {
194
- defaultLanguage: 'en',
195
- disableAutoLanguageSwitch: true,
196
- translations: { ... },
197
- }
198
-
199
- // Preferred in v2
200
- i18n: {
201
- locale: 'en',
202
- detectBrowserLanguage: false,
203
- messages: { ... },
204
- }
205
- ```
206
-
207
- If both are provided, `i18n` takes precedence.