@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
@@ -1,38 +1,26 @@
1
1
  ---
2
2
  title: Quickstart
3
3
  description: Add consent management to your Next.js app in under 5 minutes.
4
- lastModified: 2026-03-11
5
- availableIn:
6
- - framework: 'javascript'
7
- url: '/docs/frameworks/javascript/quickstart'
8
- title: 'JavaScript'
9
- - framework: 'react'
10
- url: '/docs/frameworks/react/quickstart'
11
- title: 'React'
12
- - framework: 'next'
13
- url: '/docs/frameworks/next/quickstart'
14
- title: 'Next.js'
4
+ variants:
5
+ - value: javascript
6
+ href: /docs/frameworks/javascript/quickstart
7
+ label: JavaScript
8
+ - value: react
9
+ href: /docs/frameworks/react/quickstart
10
+ label: React
11
+ - value: next
12
+ href: /docs/frameworks/next/quickstart
13
+ label: Next.js
14
+ group: frameworks
15
15
  ---
16
16
  ## Via CLI
17
17
 
18
- |Package manager|Command|
19
- |:--|:--|
20
- |npm|`npx @c15t/cli`|
21
- |pnpm|`pnpm dlx @c15t/cli`|
22
- |yarn|`yarn dlx @c15t/cli`|
23
- |bun|`bunx @c15t/cli`|
18
+ <PackageCommandTabs command="@c15t/cli" />
24
19
 
25
20
  ## Manual Installation
26
21
 
27
22
  1. **Install package**
28
23
 
29
- |Package manager|Command|
30
- |:--|:--|
31
- |npm|`npm install @c15t/nextjs`|
32
- |pnpm|`pnpm add @c15t/nextjs`|
33
- |yarn|`yarn add @c15t/nextjs`|
34
- |bun|`bun add @c15t/nextjs`|
35
-
36
24
  2. **Import styles** Import the prebuilt component stylesheet in your app-level CSS entrypoint. This is required for styled components to render correctly.
37
25
 
38
26
  ```css
@@ -42,7 +30,6 @@ availableIn:
42
30
  Keeping the c15t stylesheet in your global CSS entrypoint makes layer and cascade order explicit. JS/TSX side-effect imports can load in a different order across framework and Tailwind tooling, which makes style regressions harder to debug.With Tailwind v4, keep c15t at the end of the top-level @import block so Fumadocs, tw-animate-css, and other preset imports do not override c15t theme tokens.
43
31
 
44
32
  > ℹ️ Info:
45
- >
46
33
  > If you are using the headless API or fully custom styling, you can skip this import. Your root layout should continue importing ./globals.css as usual.
47
34
 
48
35
  3. **Create ConsentManager components** Create a provider component with the consent UI and a wrapper that re-exports it. This initializes the consent store and makes consent state available to all child components.
@@ -86,14 +73,12 @@ availableIn:
86
73
  ```
87
74
 
88
75
  > ℹ️ Info:
89
- >
90
76
  > Hosted mode is the recommended production setup because the backend resolves jurisdiction and policy, keeps durable consent records, and lets c15t recover from temporary network failures by re-syncing later.
91
77
  >
92
- > ℹ️ Info:
93
- >
78
+ > ⚠️ Warning:
94
79
  > Don't have a backend yet? You can use mode: 'offline' for local-only consent storage, but it gives up backend audit history, server-side consent awareness, and automatic jurisdiction detection. Review the browser-only storage consequences before choosing it for production.
95
80
 
96
- 4. **Mount ConsentManager at the app root** Wrap your app tree with ConsentManager so all routes/components can access consent state.
81
+ 4. **Mount ConsentManager at the app root** Wrap your app tree with `ConsentManager` so all routes/components can access consent state.
97
82
 
98
83
  ```tsx
99
84
  import { ConsentManager } from '@/components/consent-manager';
@@ -111,7 +96,9 @@ availableIn:
111
96
 
112
97
  5. **Verify it works** Start your development server and confirm:
113
98
 
114
- A consent banner appears at the bottom of the pageClicking "Customize" opens a dialog with toggles for each consent categoryAfter accepting or rejecting, the banner dismisses and your choice persists across page reloads
99
+ 1. A **consent banner** appears at the bottom of the page
100
+ 2. Clicking **"Customize"** opens a dialog with toggles for each consent category
101
+ 3. After accepting or rejecting, the banner dismisses and your choice persists across page reloads
115
102
 
116
103
  > ℹ️ **Info:**
117
104
  > Want better performance and static-route support? See Optimization for rewrites, prefetching, and network tuning. If you want server-side data prefetching, see Server-Side Data Fetching.
@@ -120,12 +107,7 @@ availableIn:
120
107
 
121
108
  Install DevTools only if you want a runtime inspector while building and debugging:
122
109
 
123
- |Package manager|Command|
124
- |:--|:--|
125
- |npm|`npm install @c15t/dev-tools`|
126
- |pnpm|`pnpm add @c15t/dev-tools`|
127
- |yarn|`yarn add @c15t/dev-tools`|
128
- |bun|`bun add @c15t/dev-tools`|
110
+ <PackageCommandTabs mode="install" command="@c15t/dev-tools" />
129
111
 
130
112
  Then add it inside your existing provider:
131
113
 
@@ -149,13 +131,15 @@ import { DevTools } from '@c15t/dev-tools/react';
149
131
 
150
132
  Install c15t agent skills to let AI agents help with styling, i18n, scripts & other configuration.
151
133
 
152
- |Package manager|Command|
153
- |:--|:--|
154
- |npm|`npx @c15t/cli skills`|
155
- |pnpm|`pnpm dlx @c15t/cli skills`|
156
- |yarn|`yarn dlx @c15t/cli skills`|
157
- |bun|`bunx @c15t/cli skills`|
134
+ <PackageCommandTabs command="@c15t/cli skills" />
158
135
 
159
136
  See [AI Agents](/docs/ai-agents) for bundled package docs and agent skills.
160
137
 
161
138
  ## Next steps
139
+
140
+ * [Optimization](/docs/frameworks/next/optimization)
141
+ * [Script Loader](/docs/frameworks/next/script-loader)
142
+ * [Styling](/docs/frameworks/next/styling/overview)
143
+ * [Consent Categories](/docs/frameworks/next/concepts/consent-categories)
144
+ * [Components](/docs/frameworks/next/components/consent-banner)
145
+ * [AI Agents](/docs/ai-agents)
@@ -1,22 +1,20 @@
1
1
  ---
2
2
  title: Script Loader
3
- description: Gate third-party scripts behind consent in Next.js — load Google Analytics, Meta Pixel, and other tracking scripts only when users grant permission.
3
+ description: Gate third-party scripts behind consent in Next.js — load Google
4
+ Analytics, Meta Pixel, and other tracking scripts only when users grant
5
+ permission.
6
+ group: frameworks
4
7
  ---
5
8
  The script loader manages third-party JavaScript based on consent state. You declare scripts in your provider's `scripts` option, and c15t decides when each script should load, stay loaded, unload, or receive a consent update.
6
9
 
7
10
  Use it for analytics, pixels, tag managers, product analytics, and other vendor snippets that should not run until the right consent condition is satisfied. Prebuilt helpers live in [`@c15t/scripts`](/docs/integrations/overview); custom scripts can be declared directly when the vendor is specific to your app.
8
11
 
9
- |Package manager|Command|
10
- |:--|:--|
11
- |npm|`npm install @c15t/scripts`|
12
- |pnpm|`pnpm add @c15t/scripts`|
13
- |yarn|`yarn add @c15t/scripts`|
14
- |bun|`bun add @c15t/scripts`|
12
+ <PackageCommandTabs mode="install" command="@c15t/scripts" />
15
13
 
16
14
  > ℹ️ **Info:**
17
15
  > Start with the integrations overview before writing your own script. Built-in helpers encode vendor boot order, consent updates, and common defaults so you do not have to.
18
16
  >
19
- > ℹ️ **Info:**
17
+ > 📝 **Note:**
20
18
  > If you need a vendor c15t does not ship yet, see the custom integration guide. It explains when a one-off Script is enough and when to build a reusable manifest-backed helper.
21
19
  >
22
20
  > ℹ️ **Info:**
@@ -186,6 +184,8 @@ Some vendors are not just script tags. YouTube embeds, maps, calendars, and chec
186
184
 
187
185
  * For iframe-only embeds, gate the iframe `src` with the [iframe blocking](/docs/frameworks/react/iframe-blocking) pattern instead of loading a script just to hide an iframe.
188
186
  * For SDK-backed UI, use the script loader for the shared SDK and render the component only when consent and SDK readiness agree.
187
+ * Use `YouTubeEmbed` for the iframe-only YouTube candidate and `GoogleMap` for the callback-based SDK candidate.
188
+ * Use `useConsentScript()` when building custom wrappers. It registers scripts through the consent store, follows `loadedScripts`, and returns a promise-shaped readiness contract for callback-based SDKs.
189
189
 
190
190
  ## Lifecycle Callbacks
191
191
 
@@ -298,6 +298,8 @@ Control where the script is injected and whether the element id is anonymized:
298
298
 
299
299
  Set `anonymizeId: false` only when another script or test needs a stable DOM id. Pass `nonce` when your CSP requires it; c15t applies it directly to the generated `<script>` element.
300
300
 
301
+ You usually do not need a per-script `nonce`. Setting `nonce` once on the provider covers every injected script (and the theme stylesheet); a per-script value overrides it for that script alone.
302
+
301
303
  ## Dynamic Management
302
304
 
303
305
  Framework packages expose script-manager methods so integrations can be added, removed, or inspected at runtime. Use this for tenant-specific tools, feature-flagged scripts, or vendors that are configured after sign-in:
@@ -422,98 +424,78 @@ export function WorkspaceAnalytics({ workspaceId }: { workspaceId: string }) {
422
424
 
423
425
  Some integrations need a visible component, not just a script tag. Google Maps, YouTube, checkout widgets, and calendars all need consent gating plus component lifecycle.
424
426
 
425
- Split the problem into three layers:
427
+ Use the [Google Maps](/docs/integrations/google-maps) and
428
+ [YouTube](/docs/integrations/youtube) renderable integrations through
429
+ `@c15t/nextjs` in client components:
430
+
431
+ ```tsx
432
+ 'use client';
433
+
434
+ import { GoogleMap, YouTubeEmbed } from '@c15t/nextjs';
435
+
436
+ export function ConsentAwareMedia() {
437
+ const googleMapsApiKey = process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY;
438
+
439
+ return (
440
+ <>
441
+ {googleMapsApiKey && (
442
+ <GoogleMap
443
+ apiKey={googleMapsApiKey}
444
+ authReferrerPolicy="origin"
445
+ center={{ lat: 40.7128, lng: -74.006 }}
446
+ className="overflow-hidden rounded-xl"
447
+ consentCategory="measurement"
448
+ zoom={12}
449
+ />
450
+ )}
451
+
452
+ <YouTubeEmbed
453
+ consentCategory="marketing"
454
+ title="Product demo"
455
+ videoId="dQw4w9WgXcQ"
456
+ />
457
+ </>
458
+ );
459
+ }
460
+ ```
461
+
462
+ The implementation splits the problem into three layers:
426
463
 
427
464
  1. Use the script loader as the source of truth for shared SDK loading.
428
- 2. Render a placeholder until consent is granted.
465
+ 2. Use `useConsentScript()` for SDK readiness when a vendor uses a callback-style loader.
429
466
  3. Create the widget instance only on the client and clean it up on unmount.
430
467
 
431
- For iframe-only embeds, use the [iframe blocking](/docs/frameworks/next/iframe-blocking) pattern. For SDK-backed widgets, load the SDK once and let each component instance create and clean up its own widget. Avoid mixing `next/script` with c15t for the same vendor.
468
+ Google Maps is SDK-backed and uses one shared c15t-managed script plus per-component map instances. The script is never requested before consent. Once loaded, its manager registration is retained to respect Google's one-loader-per-page constraint, while each map instance is destroyed on unmount or when consent becomes unavailable. The component adopts an existing Google Maps global, has a visible `320px` default height, uses the official API types, and reports loader, authentication, and constructor failures through `onError` and `errorFallback`.
469
+
470
+ All maps with the same `scriptId` must use the same loader configuration. `mapId` changes recreate the instance; `center`, `zoom`, and updateable `options` update it in place. You can pass Google's direct-loader options through `libraries`, `language`, `region`, `version`, `authReferrerPolicy`, `mapIds`, `channel`, and `solutionChannel`.
471
+
472
+ YouTube is iframe-only and uses the existing `Frame` boundary rather than the
473
+ YouTube iframe API. It defaults to a responsive, borderless 16:9 frame with a
474
+ localized loading state, stable placeholder dimensions, native lazy loading,
475
+ and the privacy-enhanced host. Its `className` and forwarded ref target the
476
+ iframe; `wrapperClassName` and `frameProps` target the `Frame`. Boolean `params`
477
+ become `1` or `0`.
478
+
479
+ For a custom client-side SDK, `useConsentScript()` exposes `blocked`, `loading`,
480
+ `ready`, and `error` states plus `readyValue`, `error`, and `ready`. Change its
481
+ `retryKey` after a failed attempt to retry the same script id. Registrations
482
+ with one id must use compatible script and readiness options; conflicts surface
483
+ as `ConsentScriptConflictError`.
484
+
485
+ For iframe-only embeds, use the [iframe blocking](/docs/frameworks/next/iframe-blocking) pattern or `YouTubeEmbed`. For SDK-backed widgets, load the SDK once and let each component instance create and clean up its own widget. Avoid mixing `next/script` with c15t for the same vendor.
432
486
 
433
487
  ## App Router Notes
434
488
 
435
489
  * The provider and any component that calls `useConsentManager()` must be client components.
436
490
  * Keep vendor ids out of static examples when they differ per environment — read them from `process.env.NEXT_PUBLIC_*` or runtime config.
437
491
  * If a script must be available before a page becomes interactive, prefer a built-in helper that models denied-consent defaults rather than adding a separate `next/script` tag.
438
- * If you use CSP nonces, pass the nonce through the `Script` object so c15t applies it to the generated script element.
492
+ * If you use CSP nonces, set `nonce` on the provider options so c15t applies it to every injected script element and the theme stylesheet. See [Content Security Policy](/docs/frameworks/next/components/consent-manager-provider#content-security-policy) for reading the nonce in the App Router.
439
493
 
440
494
  ## API Reference
441
495
 
442
- ### Script
443
-
444
- |Property|Type|Description|Default|Required|
445
- |:--|:--|:--|:--|:--:|
446
- |id|string|Unique identifier for the script|-|✅ Required|
447
- |src|string \|undefined|URL of the script to load|-|Optional|
448
- |textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
449
- |category|HasCondition\<AllConsentNames>|Consent category or condition required to load this script|-|✅ Required|
450
- |callbackOnly|boolean \|undefined|Whether this is a callback-only script that doesn't need to load an external resource. When true, no script tag will be added to the DOM, only callbacks will be executed.|false|Optional|
451
- |persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|false|Optional|
452
- |alwaysLoad|boolean \|undefined|Whether the script should always load regardless of consent state. This is useful for scripts like Google Tag Manager or PostHog that manage their own consent state internally. The script will load immediately and never be unloaded based on consent changes. Note: When using this option, you are responsible for ensuring the script itself respects user consent preferences through its own consent management.|false|Optional|
453
- |fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
454
- |attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
455
- |async|boolean \|undefined|Whether to use async loading|-|Optional|
456
- |defer|boolean \|undefined|Whether to defer script loading|-|Optional|
457
- |nonce|string \|undefined|Content Security Policy nonce|-|Optional|
458
- |anonymizeId|boolean \|undefined|Whether to use an anonymized ID for the script element, this helps ensure the script is not blocked by ad blockers|true|Optional|
459
- |target|"head" \|"body" \|undefined|Where to inject the script element in the DOM. Options: \`'head'\`: Scripts are appended to \`\<head>\` (default); \`'body'\`: Scripts are appended to \`\<body>\`|'head'|Optional|
460
- |onBeforeLoad|Object \|undefined|Callback executed before the script is loaded|-|Optional|
461
- |onLoad|Object \|undefined|Callback executed when the script loads successfully|-|Optional|
462
- |onError|Object \|undefined|Callback executed if the script fails to load|-|Optional|
463
- |onConsentChange|Object \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
464
- |vendorId|string \|number \|undefined|IAB TCF vendor ID - links script to a registered vendor. When in IAB mode, the script will only load if this vendor has consent. Takes precedence over \`category\` when in IAB mode. Use custom vendor IDs (string or number) to gate non-IAB vendors too.|-|Optional|
465
- |iabPurposes|number\[] \|undefined|IAB TCF purpose IDs this script requires consent for. When in IAB mode and no vendorId is set, the script will only load if ALL specified purposes have consent.|-|Optional|
466
- |iabLegIntPurposes|number\[] \|undefined|IAB TCF legitimate interest purpose IDs. These purposes can operate under legitimate interest instead of consent. The script loads if all iabPurposes have consent OR all iabLegIntPurposes have legitimate interest established.|-|Optional|
467
- |iabSpecialFeatures|number\[] \|undefined|IAB TCF special feature IDs this script requires. Options: 1: Use precise geolocation data; 2: Actively scan device characteristics for identification|-|Optional|
468
-
469
- #### `onBeforeLoad`
470
-
471
- Callback executed before the script is loaded
472
-
473
- |Property|Type|Description|Default|Required|
474
- |:--|:--|:--|:--|:--:|
475
- |id|string|The original script ID|-|✅ Required|
476
- |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
477
- |hasConsent|boolean|Has consent|-|✅ Required|
478
- |consents|ConsentState|The current consent state|-|✅ Required|
479
- |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
480
- |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
481
-
482
- #### `onLoad`
483
-
484
- Callback executed when the script loads successfully
485
-
486
- |Property|Type|Description|Default|Required|
487
- |:--|:--|:--|:--|:--:|
488
- |id|string|The original script ID|-|✅ Required|
489
- |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
490
- |hasConsent|boolean|Has consent|-|✅ Required|
491
- |consents|ConsentState|The current consent state|-|✅ Required|
492
- |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
493
- |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
494
-
495
- #### `onError`
496
-
497
- Callback executed if the script fails to load
498
-
499
- |Property|Type|Description|Default|Required|
500
- |:--|:--|:--|:--|:--:|
501
- |id|string|The original script ID|-|✅ Required|
502
- |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
503
- |hasConsent|boolean|Has consent|-|✅ Required|
504
- |consents|ConsentState|The current consent state|-|✅ Required|
505
- |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
506
- |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
507
-
508
- #### `onConsentChange`
509
-
510
- Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.
511
-
512
- |Property|Type|Description|Default|Required|
513
- |:--|:--|:--|:--|:--:|
514
- |id|string|The original script ID|-|✅ Required|
515
- |elementId|string|The actual DOM element ID used (anonymized if enabled)|-|✅ Required|
516
- |hasConsent|boolean|Has consent|-|✅ Required|
517
- |consents|ConsentState|The current consent state|-|✅ Required|
518
- |element|HTMLScriptElement \|undefined|The script element (for load/error callbacks) Will be undefined for callback-only scripts|-|Optional|
519
- |error|Error \|undefined|Error information (for error callbacks)|-|Optional|
496
+ |Property|Value|
497
+ |:--|:--|
498
+ |Type Name|\`Script\`|
499
+ |Source Path|\`./packages/core/src/libs/script-loader/types.ts\`|
500
+
501
+ \*ExtractedTypeTable: Could not extract "Script" from "./packages/core/src/libs/script-loader/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
@@ -1,6 +1,8 @@
1
1
  ---
2
2
  title: Server-Side Data Fetching
3
- description: Pre-fetch consent data in Server Components with fetchInitialData for dynamic Next.js routes.
3
+ description: Pre-fetch consent data in Server Components with fetchInitialData
4
+ for dynamic Next.js routes.
5
+ group: frameworks
4
6
  ---
5
7
  The `@c15t/nextjs` package provides `fetchInitialData`, a server-side function that fetches consent data before rendering. Use it when the route is already dynamic, or when you want the fastest first banner and are okay opting the route into dynamic rendering. If you need to keep a route fully static, use `C15tPrefetch` instead.
6
8
 
@@ -27,7 +29,7 @@ const ssrData = fetchInitialData({
27
29
  });
28
30
  ```
29
31
 
30
- > ℹ️ **Info:**
32
+ > ⚠️ **Warning:**
31
33
  > Do not await fetchInitialData() in Server Components. Pass the Promise directly to your client component so Next.js can stream the page while the consent data loads in parallel.
32
34
  >
33
35
  > ℹ️ **Info:**
@@ -48,29 +50,24 @@ sequenceDiagram
48
50
  participant BE as c15t Backend
49
51
 
50
52
  SC->>BE: fetchInitialData() → GET /init
51
- Note right of SC: Returns a Promise - (not awaited)
52
- SC->>NR: Render page tree - (Promise passed as prop)
53
+ Note right of SC: Returns a Promise<br/>(not awaited)
54
+ SC->>NR: Render page tree<br/>(Promise passed as prop)
53
55
  NR->>BR: Stream initial HTML
54
56
  BR->>BR: Hydrate — no consent data yet
55
57
 
56
58
  BE-->>NR: /init response resolves
57
59
  NR->>BR: Stream resolved data chunk
58
- BR->>BR: Provider receives SSR data - skips client-side /init fetch
60
+ BR->>BR: Provider receives SSR data,<br/>skips client-side /init fetch
59
61
  ```
60
62
 
61
63
  ### Options
62
64
 
63
- |Property|Type|Description|Default|Required|
64
- |:--|:--|:--|:--|:--:|
65
- |nextCache|NextCacheOptions \|undefined|Optional Next.js cache controls for SSR init requests.|-|Optional|
66
-
67
- #### `nextCache` NextCacheOptions
68
-
69
- Optional Next.js cache controls for SSR init requests.
65
+ |Property|Value|
66
+ |:--|:--|
67
+ |Type Name|\`FetchInitialDataOptions\`|
68
+ |Source Path|\`./packages/nextjs/src/types.ts\`|
70
69
 
71
- |Property|Type|Description|Default|Required|
72
- |:--|:--|:--|:--|:--:|
73
- |revalidateSeconds|number \|false \|undefined|Cache lifetime in seconds for the Next.js data cache. Set to false to disable Next.js caching for this call.|-|Optional|
70
+ \*ExtractedTypeTable: Could not extract "FetchInitialDataOptions" from "./packages/nextjs/src/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
74
71
 
75
72
  ### Return Value
76
73
 
@@ -1,6 +1,8 @@
1
1
  ---
2
2
  title: Class Names
3
- description: Style consent components using className props and per-slot className targeting via the theme.
3
+ description: Style consent components using className props and per-slot
4
+ className targeting via the theme.
5
+ group: frameworks
4
6
  ---
5
7
  ## Prefer Slots for Stock Components
6
8
 
@@ -1,6 +1,8 @@
1
1
  ---
2
2
  title: Color Scheme
3
- description: Support light mode, dark mode, and system preference detection in consent components.
3
+ description: Support light mode, dark mode, and system preference detection in
4
+ consent components.
5
+ group: frameworks
4
6
  ---
5
7
  c15t supports light and dark mode through the theme's `colors` and `dark` token groups. The active color scheme is determined by one of three methods:
6
8
 
@@ -0,0 +1,53 @@
1
+ ---
2
+ title: CSS Variables
3
+ description: Reference for all --c15t-* CSS custom properties generated by the theme system.
4
+ group: frameworks
5
+ ---
6
+ Every theme token is converted to a `--c15t-*` CSS custom property at runtime. You can override these variables in your stylesheet without using the JavaScript theme API.
7
+
8
+ ## Variable Reference
9
+
10
+ |Property|Value|
11
+ |:--|:--|
12
+ |Type Name|\`ThemeCSSVariables\`|
13
+ |Source Path|\`./packages/ui/src/theme/types.ts\`|
14
+
15
+ \*ExtractedTypeTable: Could not extract "ThemeCSSVariables" from "./packages/ui/src/theme/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
16
+
17
+ ## Overriding Variables
18
+
19
+ Override in your stylesheet:
20
+
21
+ ```css
22
+ :root {
23
+ --c15t-primary: #8b5cf6;
24
+ --c15t-surface: #fafafa;
25
+ --c15t-radius-md: 1rem;
26
+ }
27
+
28
+ /* Dark mode overrides */
29
+ .dark,
30
+ .c15t-dark {
31
+ --c15t-primary: #a78bfa;
32
+ --c15t-surface: #18181b;
33
+ --c15t-text: #fafafa;
34
+ }
35
+ ```
36
+
37
+ ## Scoped Overrides
38
+
39
+ Target specific components by scoping variables:
40
+
41
+ ```tsx
42
+ <div className="checkout-consent">
43
+ <ConsentBanner />
44
+ </div>
45
+ ```
46
+
47
+ ```css
48
+ /* Only affect c15t components inside .checkout-consent */
49
+ .checkout-consent {
50
+ --c15t-surface: #f0f9ff;
51
+ --c15t-radius-lg: 1.5rem;
52
+ }
53
+ ```