@c15t/nextjs 2.2.0 → 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,148 +1,138 @@
1
1
  ---
2
- title: Troubleshooting
3
- description: Solutions for common issues with @c15t/nextjs — provider errors,
4
- missing banners, consent persistence, and more.
2
+ title: Troubleshoot Next.js consent
3
+ description: Diagnose failed Next.js prefetch, verify manifest requests, and fix
4
+ consent rendering or persistence problems.
5
5
  group: frameworks
6
6
  ---
7
- ## "Provider not found" Error
8
7
 
9
- **Symptom:** `useConsentManager must be used within a ConsentManagerProvider` error.
10
-
11
- **Fix:** Ensure the component calling `useConsentManager()` (or any c15t hook) is rendered inside a `ConsentManagerProvider`:
12
-
13
- ```tsx
14
- // Wrong — hook is outside the provider
15
- function App() {
16
- const { consents } = useConsentManager(); // throws
17
- return <ConsentManagerProvider options={...}>...</ConsentManagerProvider>;
18
- }
19
-
20
- // Correct — hook is inside the provider
21
- function App() {
22
- return (
23
- <ConsentManagerProvider options={...}>
24
- <MyComponent /> {/* useConsentManager works here */}
25
- </ConsentManagerProvider>
26
- );
27
- }
28
- ```
29
-
30
- ## Banner Doesn't Show
31
-
32
- **Possible causes:**
33
-
34
- 1. **Opt-out jurisdiction** — In CCPA/opt-out regions, the banner is not shown because tracking is allowed by default. Check `model` from `useConsentManager()` — if it's `'opt-out'`, the banner is intentionally hidden.
35
-
36
- 2. **Consent already given** — If the user has already made a consent choice, the banner won't reappear. Clear cookies or use `resetConsents()` to test again.
37
-
38
- 3. **`activeUI` is `'none'`** — Something is explicitly setting `activeUI` to `'none'`. Check the DevTools panel for the current consent state.
39
-
40
- 4. **Backend not responding** — In `'c15t'` mode, the banner waits for the backend `/init` response. Check the Network tab for failed requests to your `backendURL`.
41
-
42
- ```tsx
43
- // Debug: check what the consent manager sees
44
- const { activeUI, model, isLoadingConsentInfo } = useConsentManager();
45
- console.log({ activeUI, model, isLoadingConsentInfo });
46
- ```
47
-
48
- ## Consent Not Persisting
49
-
50
- **Symptom:** Consent is lost after page reload.
51
-
52
- **Possible causes:**
53
-
54
- 1. **Incognito/private mode** — Some browsers restrict cookie storage in private browsing.
55
-
56
- 2. **Cookie settings** — In `'offline'` mode, consent is stored in cookies. Ensure cookies are not being blocked by browser settings or extensions.
57
-
58
- 3. **Different domains** — Cookies are domain-scoped. If your dev server uses a different domain than production, consent won't carry over.
59
-
60
- 4. **Backend errors** — In `'c15t'` mode, check that the backend is saving consent successfully. Enable `debug: true` in provider options to see detailed logs.
61
-
62
- ## Scripts Not Loading
63
-
64
- **Symptom:** Third-party scripts configured in the `scripts` option don't load after consent is granted.
65
-
66
- **Checklist:**
67
-
68
- 1. **Wrong category name** — The `category` on the script must match one of the `consentCategories` names. For example, `'measurement'` not `'analytics'`.
69
-
70
- 2. **Consent condition not met** — Use `has('measurement')` to verify the category is actually consented.
71
-
72
- 3. **Script error** — Check the browser DevTools Console for script loading errors. The `onError` callback can help debug:
73
-
74
- ```tsx
75
- {
76
- id: 'analytics',
77
- src: 'https://...',
78
- category: 'measurement',
79
- onError: ({ error }) => console.error('Script failed:', error),
80
- }
81
- ```
82
-
83
- 4. **Ad blocker** — Browser extensions may block the script regardless of consent. The `anonymizeId` option (default: `true`) helps avoid pattern-based blocking.
84
-
85
- ## SSR Hydration Mismatch
86
-
87
- **Symptom:** React hydration warnings, consent banner flashes briefly, or consent state differs between server and client.
88
-
89
- **Fixes:**
90
-
91
- 1. **Missing `ssrData`** — Ensure you're passing the SSR data Promise to the provider. Do **not** `await` `fetchInitialData()` in Server Components:
92
-
93
- ```tsx title="app/layout.tsx"
94
- import { fetchInitialData } from '@c15t/nextjs';
95
- import ConsentManager from '@/components/consent-manager';
96
-
97
- export default function RootLayout({ children }: { children: React.ReactNode }) {
98
- const ssrData = fetchInitialData({ backendURL: '/api/c15t' });
99
-
100
- return (
101
- <html lang="en">
102
- <body>
103
- <ConsentManager ssrData={ssrData}>
104
- {children}
105
- </ConsentManager>
106
- </body>
107
- </html>
108
- );
109
- }
110
- ```
111
-
112
- 2. **Stale cache** — If using a CDN or caching layer, ensure the SSR data is fresh per-request and not shared across users.
113
-
114
- 3. **Debug with `useSSRStatus`** — Check if SSR data was actually consumed:
115
-
116
- ```tsx
117
- const { ssrDataUsed, ssrSkippedReason } = useSSRStatus();
118
- ```
119
-
120
- See [Server-Side Data Fetching](/docs/frameworks/next/server-side) for full SSR setup.
121
-
122
- ## TypeScript Errors
123
-
124
- **Common import issues:**
125
-
126
- ```tsx
127
- // Components and hooks — main entry point
128
- import { ConsentManagerProvider, useConsentManager } from '@c15t/nextjs';
129
-
130
- // Server-side data fetching
131
- import { fetchInitialData } from '@c15t/nextjs';
132
-
133
- // Headless (hooks only, no components)
134
- import { useConsentManager } from '@c15t/nextjs/headless';
135
- ```
136
-
137
- If you see type errors after updating, try:
138
-
139
- ```sh
140
- rm -rf node_modules/.cache
141
- bun install
142
- ```
143
-
144
- ## Still Stuck?
145
-
146
- * Enable `debug: true` in provider options for verbose console logging
147
- * Use the [DevTools](/docs/frameworks/next/components/dev-tools) panel to inspect live consent state
148
- * Check the [GitHub issues](https://github.com/c15t/c15t/issues) for known bugs
8
+ ## Why does the page render when consent prefetch fails?
9
+
10
+ `resolveConsent` returns its baseline state when a manifest or
11
+ backend request fails. The page can still render, and the client retries
12
+ initialization. Until policy resolution succeeds, optional categories stay
13
+ denied and the stock banner stays hidden.
14
+
15
+ Pass `onError` to `resolveConsent` to report failures in production.
16
+ Without it, the helper logs a warning only outside production. Check the failed
17
+ URL and response in your server logs, as browser Network tools cannot show a
18
+ server-side fetch.
19
+
20
+ If the local manifest handler repeatedly calls itself, check its upstream URL.
21
+ `C15T_BACKEND_URL` must be the absolute Inth or self-hosted backend endpoint.
22
+ The browser can use `/api/c15t` with an optional rewrite, but that local prefix
23
+ must not become the handler's upstream backend. See
24
+ [Next.js optimization](./optimization.md) for the rewrite setup.
25
+
26
+ ## How do I verify manifest fetching?
27
+
28
+ Check the Next.js server and browser requests after following the
29
+ [App Router](./app-router.md) or
30
+ [Pages Router](./pages-router.md) guide:
31
+
32
+ 1. Load the page twice. A warm manifest setup resolves policy without calling
33
+ the upstream backend `/init`. A browser request to your local
34
+ `/api/c15t/init` is expected when client initialization is needed.
35
+ 2. Make a consent choice. Confirm the submission reaches the backend
36
+ `/subjects` endpoint and reload to check that the choice persists.
37
+ 3. Test two locations with different configured policies. Confirm the resolved
38
+ policy matches each location and that your host passes trusted geography
39
+ headers to Next.js.
40
+ 4. Change a policy, then check it after the manifest caches refresh. Cache the
41
+ public manifest, never the visitor-specific init response.
42
+ 5. If you added a rewrite, confirm browser consent requests use `/api/c15t`,
43
+ including submissions. Direct requests to the backend are expected when you
44
+ have not configured a rewrite.
45
+
46
+ ## Why is the visitor's location unknown on the server?
47
+
48
+ `resolveConsent` and the local init handler read the visitor's country
49
+ and region from hosting platform headers such as `cf-ipcountry` and
50
+ `x-vercel-ip-country`; c15t never derives location from an IP address itself.
51
+ Some platforms expose those headers to Next.js middleware or proxy but strip
52
+ them before Server Components and Route Handlers run, so every visitor falls
53
+ back to your unknown-location rule. Confirm it by logging
54
+ `(await headers()).get('x-vercel-ip-country')`, or your host's equivalent, in a
55
+ Server Component. If the header is missing there, add `c15tProxy` as described in
56
+ [Forward geography headers](./geography-headers.md); it
57
+ forwards the resolved values as `x-c15t-country` and `x-c15t-region`, which take
58
+ precedence everywhere c15t reads location.
59
+
60
+ ## Why does Next.js report an unstable `Date.now()` during prerendering?
61
+
62
+ The error
63
+ `Next.js encountered the unstable value Date.now() while prerendering`,
64
+ pointing at the `await resolveConsent(...)` line, comes from
65
+ `partialPrefetching: true` combined with `cacheComponents: true` (Next.js
66
+ 16.3 and later). During the runtime-prefetch stage Next.js resolves
67
+ `headers()` and then flags the `Date.now()` that follows. It only appears in
68
+ `next dev`; `next build` passes because build-time prerenders never resolve
69
+ `headers()`.
70
+
71
+ `resolveConsent` handles this itself: the default App Router request reader
72
+ calls `await connection()` from `next/server` before reading the clock, so the
73
+ component is already request-time when the clock is read. You do not need to
74
+ add `connection()` to your layout. If you still see the error on the current
75
+ release, report your Next.js version and config on
76
+ [c15t/c15t#1107](https://github.com/c15t/c15t/issues/1107).
77
+
78
+ ## Why is there no banner?
79
+
80
+ Inspect `resolution` and `promptRequirement` before changing styles. Pending or
81
+ failed initialization, no matching rule, a valid stored choice and a rule that
82
+ requires no prompt can all produce no banner for different reasons. A missing
83
+ stylesheet can also make rendered controls appear incorrectly.
84
+
85
+ Check the backend URL and Network response, then confirm the active policy for
86
+ the visitor's location. Do not solve missing UI by granting every category or
87
+ setting `enabled: false`: disabling the runtime permits optional loading.
88
+
89
+ ## Why does the UI disappear with a content blocker?
90
+
91
+ Check the browser Network panel for `ERR_BLOCKED_BY_CLIENT` or a failed dynamic
92
+ import. Older c15t builds used component filenames such as
93
+ `consent-dialog-*.js`, which some cookie-annoyance lists block. Update the c15t
94
+ packages and rebuild the app. Current component modules use neutral filenames;
95
+ public component imports stay the same. This also covers Vite development
96
+ requests used by TanStack Start and other Vite integrations.
97
+
98
+ Extensions can separately hide elements with cosmetic filters or block a
99
+ configured backend URL. Check the failed request or hidden element to distinguish
100
+ those cases from a missing component module.
101
+
102
+ ## Why does analytics run before a choice?
103
+
104
+ Check effective permission under the selected policy, then find every loader
105
+ for that vendor. Remove unconditional script tags, framework analytics plugins
106
+ and duplicate tag-manager entries. c15t's script registration only controls the
107
+ scripts registered with it.
108
+
109
+ Google helpers intentionally load with Consent Mode defaults. A Google request
110
+ is not by itself proof that its storage consent was granted. If your requirement
111
+ is no request at all, do not use an always-loaded helper unchanged.
112
+
113
+ ## Why does a choice disappear on reload?
114
+
115
+ Check whether persistence is disabled, browser storage is blocked, the origin
116
+ changed, or the receipt expired or no longer matches the current policy.
117
+ A development example with `persistence: false` deliberately resets on reload.
118
+ Do not "repair" persistence by saving permissions automatically on mount.
119
+
120
+ ## Why does hydration differ from server HTML?
121
+
122
+ Use the adapter's request helper and pass the returned configuration unchanged
123
+ to its boundary. Check that server and browser use the same backend and policy
124
+ inputs. A module-level mutable runtime on a server can share one visitor's state
125
+ with another request; create request-owned state instead.
126
+
127
+ ## Why does static hosting fail when development works?
128
+
129
+ A static host has no app server for init routes, proxies or server functions.
130
+ Use absolute external consent URLs or an explicitly local policy. Test the
131
+ production output with a static file server, not the framework dev server.
132
+
133
+ ## Why does customization do nothing?
134
+
135
+ Check the imported stylesheet, the correct token or slot, and which element
136
+ carries the state attribute. `data-variant` on a banner root is not a matching
137
+ attribute on its child card. Check cascade layers and the Tailwind version
138
+ before adding specificity. See [customization](../../customization/overview.md).
@@ -0,0 +1,60 @@
1
+ ---
2
+ title: Understand consent state
3
+ description: Distinguish policy resolution, effective permissions, explicit
4
+ choices, notices and privacy signals.
5
+ group: guides
6
+ ---
7
+
8
+ ## Use effective permissions to gate features
9
+
10
+ `effectivePermissions` answers whether a category is allowed now. It combines
11
+ the resolved policy, stored choices and privacy signals. Under an opt-out rule,
12
+ permission can be true before the visitor acts. It is not evidence of a recorded
13
+ grant.
14
+
15
+ | Task | State or API |
16
+ | ------------------------------------------- | ---------------------------------------------------- |
17
+ | Load a script or render an optional feature | `effectivePermissions`, React `useConsent(category)` |
18
+ | Inspect what the visitor confirmed | `explicitChoice` |
19
+ | Decide whether to show a prompt | `promptRequirement` |
20
+ | Explain regional behavior | `policyRule` |
21
+ | Diagnose initialization | `resolution` |
22
+
23
+ ## Record only explicit visitor actions
24
+
25
+ ```ts
26
+ // Run in the corresponding click or form-submit handler.
27
+ await kernel.commands.save('all');
28
+ await kernel.commands.save('none');
29
+ await kernel.commands.save({ marketing: false });
30
+ ```
31
+
32
+ These are three separate examples: accept, reject and a partial save. A partial
33
+ save confirms only the supplied categories and keeps the other categories'
34
+ confirmation times. Do not call all three in one handler.
35
+
36
+ `onChoiceRecorded` reports an explicit choice. `onPermissionsChanged` reports
37
+ changes in effective permissions, including changes caused by expiry or privacy
38
+ signals. Hydration must not be counted as another visitor choice.
39
+
40
+ ## Treat notices and privacy signals separately
41
+
42
+ `commands.dismissNotice()` acknowledges the current notice. It does not grant
43
+ categories or overwrite existing denials. Global Privacy Control, or GPC, is a
44
+ browser privacy signal. Its configured restrictions can change permissions
45
+ without creating an explicit choice.
46
+
47
+ A rule with `prompt: 'none'` can still require a persistent preferences entry
48
+ point. Check the policy's rights instead of hiding preferences merely because
49
+ the banner is absent. An unresolved rule is another distinct state; optional
50
+ permissions stay denied until resolution succeeds.
51
+
52
+ ## Preserve records during hydration
53
+
54
+ Server helpers return records with policy information and evaluation time.
55
+ Forward that configuration intact. Copying an allowed category into a receipt
56
+ would invent a grant and lose its original confirmation time.
57
+
58
+ Valid v2 records can be read without a startup rewrite. The next explicit action
59
+ writes the v3 format. See [migration](../upgrade-v3.md) for expiry, partial saves,
60
+ custom transports and backend contract changes.
@@ -0,0 +1,163 @@
1
+ ---
2
+ title: Data fetching and transports
3
+ description: Choose cached manifests, backend init or offline policy resolution,
4
+ and understand where consent records are saved.
5
+ group: guides
6
+ ---
7
+
8
+ ## Start with Inth and a cached manifest
9
+
10
+ Use Inth for managed policy and consent records. For a Next.js application with
11
+ a server, use a cached manifest to resolve policy in your application. Route
12
+ browser consent traffic directly to Inth, or optionally use a Next.js rewrite
13
+ to keep those requests on your app's origin. Follow the
14
+ [Next.js manifest setup](../frameworks/next/data-fetching.md).
15
+
16
+ Backend ownership and data fetching are separate decisions. Inth manages the
17
+ backend for you. A [self-hosted backend](https://c15t.com/docs/self-host/quickstart) uses the same
18
+ protocol while you operate its database, policies and availability. A static
19
+ site can still call Inth. Only `offline()` deliberately removes consent backend
20
+ requests and stores choices locally.
21
+
22
+ | Fetching path | Where policy resolves | Where choices are submitted | Choose it when |
23
+ | ------------------------------ | ------------------------------------------------------------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------ |
24
+ | Cached manifest on your server | Your application resolves public policy data with each request's location and signals | Inth or your c15t backend | Your host has a runtime server and you want to reuse policy data across requests |
25
+ | Regular backend `/init` | The consent backend | The same backend | You want the fewest moving parts, need backend-owned request resolution, or have no application server |
26
+ | Manifest in the browser | The browser, using supplied or unknown location | Inth or your c15t backend | You deliberately want client resolution and have planned geography, bundle size and policy refresh |
27
+ | Offline | The browser or local runtime, using bundled rules | No backend submission | Local development and tests. Not recommended for production environments. |
28
+ | Custom transport | Your implementation | Your implementation | An existing service cannot use the c15t backend protocol |
29
+
30
+ ## What is a consent manifest?
31
+
32
+ A manifest is a versioned policy document served by `GET /manifest`. It contains
33
+ policy rules, translation configuration and related consent configuration. It
34
+ is public configuration, not a visitor's saved choices. A resolver combines the
35
+ manifest with country, region, language and privacy signals to produce an init
36
+ result for one visitor.
37
+
38
+ Reusing the public document avoids asking the consent backend to resolve policy
39
+ for every application request. Cache misses and revalidation still fetch the
40
+ manifest, and consent writes still need the backend. Measure the deployed
41
+ request path before promising a latency improvement.
42
+
43
+ Do not put secrets, visitor identifiers or consent records into a manifest.
44
+ Keep personalized init responses out of shared caches. Changing a policy also
45
+ requires a refresh strategy for cached or build-time manifests.
46
+
47
+ ## What does regular `/init` do?
48
+
49
+ `hosted({ url })` uses `${url}/init` for initialization and `${url}/subjects` for
50
+ consent submissions. The name `hosted` describes the transport protocol; the URL
51
+ can belong to Inth or your own c15t backend.
52
+
53
+ ```ts title="src/consent-mode.ts"
54
+ import { hosted } from 'c15t';
55
+
56
+ export function createConsentMode(backendURL: string) {
57
+ return hosted({ url: backendURL });
58
+ }
59
+ ```
60
+
61
+ Pass the factory to your adapter's `mode` option. For request rendering, use the
62
+ adapter's server helper and forward its prepared result to the browser. For
63
+ static output, initialize in the browser with a reachable external URL.
64
+
65
+ A regular backend `/init` request lets the backend resolve the visitor context.
66
+ A same-origin URL named `/api/c15t/init` can instead resolve from a cached
67
+ manifest in your application. The URL name alone does not tell you which path
68
+ runs.
69
+
70
+ ## How do transports and proxies differ?
71
+
72
+ A transport implements initialization, saving and optional record operations.
73
+ A proxy changes where HTTP requests travel. It does not change the policy
74
+ resolver or make personalized responses safe to cache.
75
+
76
+ For a same-origin init route that resolves a manifest, the hosted transport can
77
+ separate policy reads and record writes. With a backend rewrite mounted at
78
+ `/api/c15t`, a client mode can use:
79
+
80
+ ```ts title="src/consent-mode.ts"
81
+ import { hosted } from 'c15t';
82
+
83
+ export const mode = hosted({
84
+ url: '/api/c15t',
85
+ initURL: '/api/c15t/init',
86
+ assertDecisionInputs: true,
87
+ });
88
+ ```
89
+
90
+ The route must return the c15t init response contract. `assertDecisionInputs`
91
+ binds saves to the resolved policy when init did not return a signed policy
92
+ snapshot token. The backend can then reject a stale policy decision. Next.js
93
+ sets this option for you when `ConsentRoot` receives a `config` with
94
+ `initURL`.
95
+
96
+ The init route resolves policy; the backend rewrite forwards `/api/c15t/subjects`
97
+ and other record endpoints. Configure both if you choose this optional proxy
98
+ variant. The
99
+ [Next.js rewrite recipe](../frameworks/next/optimization.md#keep-browser-consent-requests-on-your-origin)
100
+ shows the configuration. A direct absolute backend URL works
101
+ without a rewrite.
102
+
103
+ This optional optimization keeps c15t requests on the app's origin and avoids a separate browser DNS lookup
104
+ and TLS connection to the consent backend. The app server still connects to
105
+ the upstream backend for manifest refreshes and consent writes. Vendor scripts
106
+ and vendor requests keep their own origins.
107
+
108
+ Set the absolute upstream endpoint through `C15T_BACKEND_URL` in Next.js server
109
+ configuration. The endpoint URL is public connection information, not a secret.
110
+ The browser uses `/api/c15t` without needing the upstream URL. A static export
111
+ cannot serve a Next.js route or rewrite at runtime; use the absolute Inth URL or
112
+ a proxy provided by the static host instead.
113
+
114
+ ## When should I use offline mode?
115
+
116
+ Not recommended for production environments. Use Inth or a self-hosted backend
117
+ for production policy and consent records.
118
+
119
+ `offline()` resolves bundled policy rules without an init request and acknowledges
120
+ saves locally. The runtime's persistence module stores the choice in browser
121
+ storage. There is no backend audit history, cross-device record service or IP
122
+ geolocation supplied by this transport.
123
+
124
+ Use your adapter's offline factory so its translations and provider context are
125
+ included. This React and Next.js example replaces the hosted mode in an existing
126
+ client provider:
127
+
128
+ ```ts title="src/consent-mode.ts"
129
+ import { offline } from 'c15t/react';
130
+
131
+ export const mode = offline();
132
+ ```
133
+
134
+ With no `policyRules`, the current offline transport uses the recommended rule
135
+ pack. Supplying `policyRules` replaces that pack. Unknown country and region are
136
+ real resolution inputs; offline mode does not discover a visitor's location.
137
+ Use [policy rules](../frameworks/next/concepts/policy-presets.md) to understand
138
+ matching and defaults, and test the missing-location case.
139
+
140
+ Offline mode is an explicit architecture choice, not an automatic fallback for
141
+ a failed Inth request. If hosted initialization fails before a policy resolves,
142
+ optional permissions remain denied and the stock prompt stays hidden. Observe
143
+ initialization failures instead of silently changing policy sources.
144
+
145
+ ## Can I provide my own transport?
146
+
147
+ `custom(transport)` accepts a `KernelTransport` with the v3 `init` and `save`
148
+ contract. It does not accept v2 endpoint handlers such as `setConsent`. Keep
149
+ policy resolution, record acknowledgments and failure behavior consistent with
150
+ the kernel contract. Prefer a built-in transport when your backend supports it.
151
+
152
+ ## Verify the selected path
153
+
154
+ Inspect browser and server requests separately. A server manifest fetch will
155
+ not appear in the browser's Network panel. On a warm manifest path, check that
156
+ page requests do not call the backend `/init`, a visitor's choice still reaches
157
+ the backend's `/subjects`, and policy changes become visible after the configured
158
+ refresh. In the recommended Next.js setup, the browser should call only
159
+ `/api/c15t` paths for consent HTTP traffic; inspect server logs to verify their
160
+ upstream destinations.
161
+
162
+ Test different locations, missing location headers, GPC, returning choices and
163
+ backend failure. See [verification](./verify-consent.md).
@@ -0,0 +1,63 @@
1
+ ---
2
+ title: Choose a deployment mode
3
+ description: Choose who runs your consent backend, then select manifest, init or
4
+ offline resolution for your deployment.
5
+ group: guides
6
+ ---
7
+
8
+ ## Use Inth for managed policy and records
9
+
10
+ Start with [Inth](https://inth.com) unless you need to operate the consent
11
+ service yourself or deliberately need only local browser records. Configure
12
+ policy rules and trusted origins in the project, then use its exact backend
13
+ endpoint in your framework setup.
14
+
15
+ | Backend ownership | Policy source | Record storage | Use when |
16
+ | ------------------------- | ------------------------------------------------------ | ---------------------------------------- | ------------------------------------------------------------------------- |
17
+ | Inth hosted service | Centrally managed policy through a manifest or `/init` | Browser records plus backend submissions | You want managed policy and consent records |
18
+ | Self-hosted c15t | Your backend's manifest or `/init` | Browser records plus your database | You need to operate the service and its infrastructure |
19
+ | Browser-only offline mode | Bundled `policyRules` | Browser persistence | Local development and tests. Not recommended for production environments. |
20
+
21
+ Hosted and self-hosted c15t use the same transport protocol. Switching who runs
22
+ the backend does not require switching from manifests to `/init`.
23
+
24
+ ## Choose data fetching separately
25
+
26
+ For Next.js deployments with a runtime server, use the
27
+ [manifest setup](../frameworks/next/data-fetching.md). It reuses public policy data
28
+ in your application while consent writes still go to Inth. Regular backend
29
+ `/init` is available when you want backend-owned request resolution or a simpler
30
+ browser setup. See [data fetching and transports](./data-fetching.md) for
31
+ the comparison, including custom transports and offline mode.
32
+
33
+ ## Match initialization to your application output
34
+
35
+ | Application output | Initial state | Required setup |
36
+ | ------------------ | ------------------------- | ----------------------------------------------------------- |
37
+ | Request SSR | Prepared for this visitor | Adapter request helper and matching client configuration |
38
+ | Static HTML or SPA | Resolved in the browser | Reachable external URLs or deliberately bundled local rules |
39
+
40
+ Request SSR can include the visitor's prompt in the initial HTML. Pass the
41
+ prepared records and policy resolution through to hydration. Do not convert
42
+ effective permissions into new stored choices.
43
+
44
+ Static HTML is shared across visitors. It cannot contain a choice resolved from
45
+ each visitor's cookies or geography at build time. A static site can still use
46
+ Inth through browser requests. A same-origin `/api/c15t` URL only works if a
47
+ service actually serves it; a Next.js static export does not run API routes.
48
+
49
+ A manifest contains reusable public policy data. A resolved init response and
50
+ personalized consent HTML belong to a request. Do not give them the same shared
51
+ cache treatment.
52
+
53
+ ## Handle initialization and storage failures
54
+
55
+ While no policy resolves, optional permissions stay denied and the stock
56
+ consent UI stays hidden. No banner can mean pending or failed initialization.
57
+ It does not mean permission to load analytics. Observe errors before changing
58
+ presentation, and do not silently switch to offline policy after a hosted
59
+ request fails.
60
+
61
+ Browser storage can also be unavailable. A working in-memory interaction does
62
+ not prove the choice survives reload. Use
63
+ [verification](./verify-consent.md) to test the actual deployment.
@@ -0,0 +1,68 @@
1
+ ---
2
+ title: Troubleshoot consent
3
+ description: Diagnose missing banners, early vendor requests, lost choices and
4
+ hydration differences.
5
+ group: guides
6
+ ---
7
+
8
+ ## Why is there no banner?
9
+
10
+ Inspect `resolution` and `promptRequirement` before changing styles. Pending or
11
+ failed initialization, no matching rule, a valid stored choice and a rule that
12
+ requires no prompt can all produce no banner for different reasons. A missing
13
+ stylesheet can also make rendered controls appear incorrectly.
14
+
15
+ Check the backend URL and Network response, then confirm the active policy for
16
+ the visitor's location. Do not solve missing UI by granting every category or
17
+ setting `enabled: false`: disabling the runtime permits optional loading.
18
+
19
+ ## Why does the UI disappear with a content blocker?
20
+
21
+ Check the browser Network panel for `ERR_BLOCKED_BY_CLIENT` or a failed dynamic
22
+ import. Older c15t builds used component filenames such as
23
+ `consent-dialog-*.js`, which some cookie-annoyance lists block. Update the c15t
24
+ packages and rebuild the app. Current component modules use neutral filenames;
25
+ public component imports stay the same. This also covers Vite development
26
+ requests used by TanStack Start and other Vite integrations.
27
+
28
+ Extensions can separately hide elements with cosmetic filters or block a
29
+ configured backend URL. Check the failed request or hidden element to distinguish
30
+ those cases from a missing component module.
31
+
32
+ ## Why does analytics run before a choice?
33
+
34
+ Check effective permission under the selected policy, then find every loader
35
+ for that vendor. Remove unconditional script tags, framework analytics plugins
36
+ and duplicate tag-manager entries. c15t's script registration only controls the
37
+ scripts registered with it.
38
+
39
+ Google helpers intentionally load with Consent Mode defaults. A Google request
40
+ is not by itself proof that its storage consent was granted. If your requirement
41
+ is no request at all, do not use an always-loaded helper unchanged.
42
+
43
+ ## Why does a choice disappear on reload?
44
+
45
+ Check whether persistence is disabled, browser storage is blocked, the origin
46
+ changed, or the receipt expired or no longer matches the current policy.
47
+ A development example with `persistence: false` deliberately resets on reload.
48
+ Do not "repair" persistence by saving permissions automatically on mount.
49
+
50
+ ## Why does hydration differ from server HTML?
51
+
52
+ Use the adapter's request helper and pass the returned configuration unchanged
53
+ to its boundary. Check that server and browser use the same backend and policy
54
+ inputs. A module-level mutable runtime on a server can share one visitor's state
55
+ with another request; create request-owned state instead.
56
+
57
+ ## Why does static hosting fail when development works?
58
+
59
+ A static host has no app server for init routes, proxies or server functions.
60
+ Use absolute external consent URLs or an explicitly local policy. Test the
61
+ production output with a static file server, not the framework dev server.
62
+
63
+ ## Why does customization do nothing?
64
+
65
+ Check the imported stylesheet, the correct token or slot, and which element
66
+ carries the state attribute. `data-variant` on a banner root is not a matching
67
+ attribute on its child card. Check cascade layers and the Tailwind version
68
+ before adding specificity. See [customization](../customization/overview.md).