@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.
- package/AGENTS.md +155 -0
- package/README.md +31 -15
- package/client/components/integrations.js +3 -0
- package/dist/components/integrations/index.cjs +1 -0
- package/dist/components/integrations/index.js +1 -0
- package/dist/headless.cjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/libs/browser-initial-data.cjs +1 -1
- package/dist/libs/initial-data.cjs +1 -1
- package/dist/styles.tw3.css +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/dist-types/components/integrations/index.d.ts +1 -0
- package/dist-types/libs/browser-initial-data.d.ts +1 -1
- package/dist-types/version.d.ts +1 -1
- package/docs/README.md +155 -73
- package/docs/{building-headless-components.md → frameworks/next/building-headless-components.md} +3 -1
- package/docs/{callbacks.md → frameworks/next/callbacks.md} +3 -1
- package/docs/{components → frameworks/next/components}/consent-banner.md +10 -21
- package/docs/{components → frameworks/next/components}/consent-dialog-link.md +8 -5
- package/docs/frameworks/next/components/consent-dialog-trigger.md +202 -0
- package/docs/{components → frameworks/next/components}/consent-dialog.md +7 -15
- package/docs/frameworks/next/components/consent-manager-provider.md +327 -0
- package/docs/{components → frameworks/next/components}/consent-widget.md +8 -6
- package/docs/{components → frameworks/next/components}/dev-tools.md +9 -6
- package/docs/{components → frameworks/next/components}/frame.md +8 -9
- package/docs/{concepts → frameworks/next/concepts}/client-modes.md +4 -2
- package/docs/{concepts → frameworks/next/concepts}/consent-categories.md +1 -0
- package/docs/{concepts → frameworks/next/concepts}/consent-models.md +1 -0
- package/docs/{concepts → frameworks/next/concepts}/cookie-management.md +3 -3
- package/docs/{concepts → frameworks/next/concepts}/glossary.md +1 -0
- package/docs/{concepts → frameworks/next/concepts}/initialization-flow.md +1 -0
- package/docs/{concepts → frameworks/next/concepts}/policy-packs.md +1 -0
- package/docs/{headless.md → frameworks/next/headless.md} +3 -1
- package/docs/{hooks → frameworks/next/hooks}/use-color-scheme.md +1 -0
- package/docs/{hooks → frameworks/next/hooks}/use-consent-manager/checking-consent.md +3 -1
- package/docs/{hooks → frameworks/next/hooks}/use-consent-manager/location-info.md +3 -1
- package/docs/frameworks/next/hooks/use-consent-manager/overview.md +185 -0
- package/docs/{hooks → frameworks/next/hooks}/use-consent-manager/setting-consent.md +3 -1
- package/docs/{hooks → frameworks/next/hooks}/use-draggable.md +3 -1
- package/docs/{hooks → frameworks/next/hooks}/use-focus-trap.md +1 -0
- package/docs/{hooks → frameworks/next/hooks}/use-reduced-motion.md +3 -1
- package/docs/{hooks → frameworks/next/hooks}/use-ssr-status.md +6 -5
- package/docs/{hooks → frameworks/next/hooks}/use-text-direction.md +1 -0
- package/docs/frameworks/next/hooks/use-translations.md +55 -0
- package/docs/{iab → frameworks/next/iab}/consent-banner.md +9 -12
- package/docs/{iab → frameworks/next/iab}/consent-dialog.md +9 -14
- package/docs/{iab → frameworks/next/iab}/overview.md +4 -2
- package/docs/{iab → frameworks/next/iab}/use-gvl-data.md +3 -2
- package/docs/{iframe-blocking.md → frameworks/next/iframe-blocking.md} +8 -9
- package/docs/{internationalization.md → frameworks/next/internationalization.md} +13 -3
- package/docs/{network-blocker.md → frameworks/next/network-blocker.md} +13 -51
- package/docs/{optimization.md → frameworks/next/optimization.md} +5 -4
- package/docs/{policy-packs.md → frameworks/next/policy-packs.md} +3 -1
- package/docs/{quickstart.md → frameworks/next/quickstart.md} +26 -42
- package/docs/{script-loader.md → frameworks/next/script-loader.md} +72 -90
- package/docs/{server-side.md → frameworks/next/server-side.md} +12 -15
- package/docs/{styling → frameworks/next/styling}/classnames.md +3 -1
- package/docs/{styling → frameworks/next/styling}/color-scheme.md +3 -1
- package/docs/frameworks/next/styling/css-variables.md +53 -0
- package/docs/frameworks/next/styling/overview.md +299 -0
- package/docs/frameworks/next/styling/slots.md +94 -0
- package/docs/{styling → frameworks/next/styling}/tailwind.md +3 -1
- package/docs/frameworks/next/styling/tokens.md +156 -0
- package/docs/{troubleshooting.md → frameworks/next/troubleshooting.md} +3 -1
- package/docs/integrations/adobe-analytics.md +160 -0
- package/docs/integrations/ahrefs-analytics.md +15 -82
- package/docs/integrations/amplitude.md +230 -0
- package/docs/integrations/building-integrations.md +15 -181
- package/docs/integrations/clearbit.md +130 -0
- package/docs/integrations/cloudflare-web-analytics.md +15 -83
- package/docs/integrations/crisp.md +13 -87
- package/docs/integrations/databuddy.md +16 -85
- package/docs/integrations/fathom-analytics.md +15 -86
- package/docs/integrations/google-maps.md +263 -0
- package/docs/integrations/google-tag-manager.md +18 -86
- package/docs/integrations/google-tag.md +15 -84
- package/docs/integrations/heap.md +219 -0
- package/docs/integrations/hightouch.md +199 -0
- package/docs/integrations/hotjar.md +15 -83
- package/docs/integrations/intercom.md +13 -83
- package/docs/integrations/linkedin-insights.md +15 -82
- package/docs/integrations/logrocket.md +175 -0
- package/docs/integrations/matomo-analytics.md +13 -88
- package/docs/integrations/meta-pixel.md +33 -316
- package/docs/integrations/microsoft-clarity.md +15 -83
- package/docs/integrations/microsoft-uet.md +16 -83
- package/docs/integrations/mixpanel-analytics.md +15 -83
- package/docs/integrations/overview.md +55 -6
- package/docs/integrations/pirsch.md +142 -0
- package/docs/integrations/plausible-analytics.md +14 -97
- package/docs/integrations/posthog.md +26 -98
- package/docs/integrations/promptwatch.md +16 -82
- package/docs/integrations/reddit-pixel.md +27 -122
- package/docs/integrations/rudderstack.md +271 -0
- package/docs/integrations/rybbit-analytics.md +15 -94
- package/docs/integrations/segment.md +15 -82
- package/docs/integrations/snapchat-pixel.md +21 -102
- package/docs/integrations/tiktok-pixel.md +13 -81
- package/docs/integrations/umami-analytics.md +16 -88
- package/docs/integrations/vercel-analytics.md +13 -85
- package/docs/integrations/x-pixel.md +27 -102
- package/docs/integrations/youtube.md +193 -0
- package/docs/shared/concepts/client-modes.md +103 -0
- package/docs/shared/concepts/consent-categories.md +41 -0
- package/docs/shared/concepts/consent-models.md +72 -0
- package/docs/shared/concepts/cookie-management.md +88 -0
- package/docs/shared/concepts/glossary.md +24 -0
- package/docs/shared/concepts/initialization-flow.md +105 -0
- package/docs/shared/concepts/policy-packs.md +225 -0
- package/docs/shared/react/components/consent-banner.md +242 -0
- package/docs/shared/react/components/consent-dialog-link.md +45 -0
- package/docs/shared/react/components/consent-dialog-trigger.md +185 -0
- package/docs/shared/react/components/consent-dialog.md +119 -0
- package/docs/shared/react/components/consent-manager-provider.md +225 -0
- package/docs/shared/react/components/consent-widget.md +121 -0
- package/docs/shared/react/components/dev-tools.md +81 -0
- package/docs/shared/react/components/frame.md +52 -0
- package/docs/shared/react/guides/building-headless-components.md +110 -0
- package/docs/shared/react/guides/callbacks.md +89 -0
- package/docs/shared/react/guides/headless.md +31 -0
- package/docs/shared/react/guides/iframe-blocking.md +65 -0
- package/docs/shared/react/guides/internationalization.md +123 -0
- package/docs/shared/react/guides/network-blocker.md +72 -0
- package/docs/shared/react/guides/optimization.md +44 -0
- package/docs/shared/react/guides/policy-packs.md +173 -0
- package/docs/shared/react/guides/script-loader.md +311 -0
- package/docs/shared/react/hooks/use-color-scheme.md +31 -0
- package/docs/shared/react/hooks/use-consent-manager/checking-consent.md +95 -0
- package/docs/shared/react/hooks/use-consent-manager/location-info.md +96 -0
- package/docs/shared/react/hooks/use-consent-manager/overview.md +74 -0
- package/docs/shared/react/hooks/use-consent-manager/setting-consent.md +93 -0
- package/docs/shared/react/hooks/use-draggable.md +30 -0
- package/docs/shared/react/hooks/use-focus-trap.md +20 -0
- package/docs/shared/react/hooks/use-reduced-motion.md +33 -0
- package/docs/shared/react/hooks/use-ssr-status.md +16 -0
- package/docs/shared/react/hooks/use-text-direction.md +38 -0
- package/docs/shared/react/hooks/use-translations.md +15 -0
- package/docs/shared/react/iab/consent-banner.md +60 -0
- package/docs/shared/react/iab/consent-dialog.md +76 -0
- package/docs/shared/react/iab/overview.md +80 -0
- package/docs/shared/react/iab/use-gvl-data.md +21 -0
- package/docs/shared/react/styling/classnames.md +93 -0
- package/docs/shared/react/styling/color-scheme.md +35 -0
- package/docs/shared/react/styling/css-variables.md +53 -0
- package/docs/shared/react/styling/overview.md +261 -0
- package/docs/shared/react/styling/slots.md +93 -0
- package/docs/shared/react/styling/stylesheet-entrypoint.md +8 -0
- package/docs/shared/react/styling/tailwind.md +88 -0
- package/docs/shared/react/styling/tokens.md +155 -0
- package/docs/shared/troubleshooting.md +82 -0
- package/package.json +19 -10
- package/readme.json +14 -8
- package/docs/ai-agents.md +0 -111
- package/docs/components/consent-dialog-trigger.md +0 -103
- package/docs/components/consent-manager-provider.md +0 -425
- package/docs/hooks/use-consent-manager/overview.md +0 -420
- package/docs/hooks/use-translations.md +0 -118
- package/docs/styling/css-variables.md +0 -92
- package/docs/styling/overview.md +0 -457
- package/docs/styling/slots.md +0 -128
- package/docs/styling/tokens.md +0 -216
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ConsentManagerProvider
|
|
3
|
+
description: The root provider component that initializes the consent system and
|
|
4
|
+
makes consent state available to all child components.
|
|
5
|
+
group: frameworks
|
|
6
|
+
---
|
|
7
|
+
`ConsentManagerProvider` is the root component for the c15t consent system. It initializes the consent store, detects the user's jurisdiction, resolves translations, and provides consent state to all child components via React context.
|
|
8
|
+
|
|
9
|
+
Every other c15t component and hook must be rendered inside this provider.
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { type ReactNode } from 'react';
|
|
15
|
+
import { ConsentManagerProvider, ConsentBanner, ConsentDialog } from '@c15t/nextjs';
|
|
16
|
+
|
|
17
|
+
export default function ConsentManager({ children }: { children: ReactNode }) {
|
|
18
|
+
return (
|
|
19
|
+
<ConsentManagerProvider
|
|
20
|
+
options={{
|
|
21
|
+
mode: 'hosted',
|
|
22
|
+
backendURL: '/api/c15t',
|
|
23
|
+
consentCategories: ['necessary', 'measurement', 'marketing'],
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
<ConsentBanner />
|
|
27
|
+
<ConsentDialog />
|
|
28
|
+
{children}
|
|
29
|
+
</ConsentManagerProvider>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Options Reference
|
|
35
|
+
|
|
36
|
+
|Property|Value|
|
|
37
|
+
|:--|:--|
|
|
38
|
+
|Type Name|\`CommonInlineStoreOptions\`|
|
|
39
|
+
|Source Path|\`./packages/ui/src/theme/options.ts\`|
|
|
40
|
+
|
|
41
|
+
\*ExtractedTypeTable: Could not extract "CommonInlineStoreOptions" from "./packages/ui/src/theme/options.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
42
|
+
|
|
43
|
+
|Property|Value|
|
|
44
|
+
|:--|:--|
|
|
45
|
+
|Type Name|\`ConsentManagerContentOptions\`|
|
|
46
|
+
|Source Path|\`./packages/ui/src/theme/options.ts\`|
|
|
47
|
+
|
|
48
|
+
\*ExtractedTypeTable: Could not extract "ConsentManagerContentOptions" from "./packages/ui/src/theme/options.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
49
|
+
|
|
50
|
+
|Property|Value|
|
|
51
|
+
|:--|:--|
|
|
52
|
+
|Type Name|\`UIOptions\`|
|
|
53
|
+
|Source Path|\`./packages/ui/src/theme/types.ts\`|
|
|
54
|
+
|
|
55
|
+
\*ExtractedTypeTable: Could not extract "UIOptions" 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.\*
|
|
56
|
+
|
|
57
|
+
## Mode: hosted vs offline
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
// Hosted mode — persists to hosted backend
|
|
61
|
+
<ConsentManagerProvider
|
|
62
|
+
options={{
|
|
63
|
+
mode: 'hosted',
|
|
64
|
+
backendURL: '/api/c15t',
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
|
|
68
|
+
// Offline mode — local cookie storage only
|
|
69
|
+
<ConsentManagerProvider
|
|
70
|
+
options={{
|
|
71
|
+
mode: 'offline',
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
See [Client Modes](/docs/frameworks/next/concepts/client-modes) for a detailed comparison.
|
|
77
|
+
|
|
78
|
+
## Content Security Policy
|
|
79
|
+
|
|
80
|
+
c15t injects a `<style id="c15t-theme">` element for your theme tokens, and the script loader injects a `<script>` element per consented vendor. Under a nonce-based Content Security Policy, both are blocked unless they carry your nonce.
|
|
81
|
+
|
|
82
|
+
Pass it once through the `nonce` option and c15t applies it to everything it injects:
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
<ConsentManagerProvider
|
|
86
|
+
options={{
|
|
87
|
+
mode: 'offline',
|
|
88
|
+
nonce: yourRequestNonce,
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
91
|
+
{children}
|
|
92
|
+
</ConsentManagerProvider>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
A `nonce` set on an individual script definition still wins, so you can override a single vendor without changing the provider.
|
|
96
|
+
|
|
97
|
+
> 📝 **Note:**
|
|
98
|
+
> Browsers hide the nonce content attribute once a policy is active. Inspecting the element shows no nonce="", but element.nonce still returns the value — this is expected and not a sign that c15t dropped it.
|
|
99
|
+
|
|
100
|
+
### Inline style attributes
|
|
101
|
+
|
|
102
|
+
The `nonce` option covers the elements c15t injects. It cannot cover inline `style="..."` attributes, which several components rely on — a nonce never authorizes a style attribute, because nonces apply to elements only.
|
|
103
|
+
|
|
104
|
+
Style attributes are governed by `style-src-attr`, and when that directive is absent CSP falls back to `style-src`. A nonce-based style policy therefore blocks them:
|
|
105
|
+
|
|
106
|
+
```http
|
|
107
|
+
style-src 'self' 'nonce-abc123';
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
To keep the nonce requirement for stylesheets while still allowing style attributes, set `style-src-attr` explicitly:
|
|
111
|
+
|
|
112
|
+
```http
|
|
113
|
+
style-src 'self' 'nonce-abc123';
|
|
114
|
+
style-src-attr 'unsafe-inline';
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
> ⚠️ **Warning:**
|
|
118
|
+
> 'unsafe-inline' on style-src-attr permits any inline style attribute on the page. That is weaker than a nonce, but far narrower than replacing your nonce-based style-src with 'unsafe-inline', which would additionally authorize arbitrary injected \<style> elements. Note that adding 'unsafe-inline' alongside a nonce achieves nothing — a directive that specifies a nonce ignores it. If your threat model does not allow this, expect components that use inline styles to render unstyled.
|
|
119
|
+
|
|
120
|
+
### Reading the nonce in the App Router
|
|
121
|
+
|
|
122
|
+
Next.js does not expose the request nonce to client components, so read it in a server component and pass it down. Generate the nonce in middleware, forward it on a request header, then hand it to the provider from your layout:
|
|
123
|
+
|
|
124
|
+
```ts title="middleware.ts"
|
|
125
|
+
import { NextResponse, type NextRequest } from 'next/server';
|
|
126
|
+
|
|
127
|
+
export function middleware(request: NextRequest) {
|
|
128
|
+
const nonce = crypto.randomUUID();
|
|
129
|
+
const isDev = process.env.NODE_ENV === 'development';
|
|
130
|
+
|
|
131
|
+
const csp = [
|
|
132
|
+
`default-src 'self'`,
|
|
133
|
+
// Next.js dev tooling (React Refresh and HMR) requires 'unsafe-eval'.
|
|
134
|
+
`script-src 'self' 'nonce-${nonce}'${isDev ? " 'unsafe-eval'" : ''}`,
|
|
135
|
+
`style-src 'self' 'nonce-${nonce}'`,
|
|
136
|
+
// Nonces cannot authorize inline style attributes — see above.
|
|
137
|
+
`style-src-attr 'unsafe-inline'`,
|
|
138
|
+
].join('; ');
|
|
139
|
+
|
|
140
|
+
const requestHeaders = new Headers(request.headers);
|
|
141
|
+
requestHeaders.set('x-nonce', nonce);
|
|
142
|
+
requestHeaders.set('Content-Security-Policy', csp);
|
|
143
|
+
|
|
144
|
+
const response = NextResponse.next({ request: { headers: requestHeaders } });
|
|
145
|
+
response.headers.set('Content-Security-Policy', csp);
|
|
146
|
+
|
|
147
|
+
return response;
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
> ⚠️ **Warning:**
|
|
152
|
+
> Set the same policy on both the forwarded request headers and the response. Next.js reads the nonce for its own runtime and hydration scripts from the Content-Security-Policy request header during rendering. Setting it only on the response leaves those scripts without a nonce, and the enforced policy then blocks them, so the page never hydrates.
|
|
153
|
+
|
|
154
|
+
```tsx title="app/layout.tsx"
|
|
155
|
+
import { headers } from 'next/headers';
|
|
156
|
+
import { ConsentManagerProvider } from '@c15t/nextjs';
|
|
157
|
+
|
|
158
|
+
export default async function RootLayout({
|
|
159
|
+
children,
|
|
160
|
+
}: {
|
|
161
|
+
children: React.ReactNode;
|
|
162
|
+
}) {
|
|
163
|
+
const nonce = (await headers()).get('x-nonce') ?? undefined;
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<html lang="en">
|
|
167
|
+
<body>
|
|
168
|
+
<ConsentManagerProvider options={{ mode: 'offline', nonce }}>
|
|
169
|
+
{children}
|
|
170
|
+
</ConsentManagerProvider>
|
|
171
|
+
</body>
|
|
172
|
+
</html>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Legal Links
|
|
178
|
+
|
|
179
|
+
`legalLinks` defines the URLs shown in consent UI text (banner, dialog, and widget where applicable).
|
|
180
|
+
Configure only the links you want to expose.
|
|
181
|
+
|
|
182
|
+
```tsx
|
|
183
|
+
<ConsentManagerProvider
|
|
184
|
+
options={{
|
|
185
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
186
|
+
legalLinks: {
|
|
187
|
+
privacyPolicy: {
|
|
188
|
+
href: '/privacy',
|
|
189
|
+
target: '_self',
|
|
190
|
+
},
|
|
191
|
+
cookiePolicy: {
|
|
192
|
+
href: '/cookies',
|
|
193
|
+
target: '_self',
|
|
194
|
+
},
|
|
195
|
+
termsOfService: {
|
|
196
|
+
href: 'https://example.com/terms',
|
|
197
|
+
target: '_blank',
|
|
198
|
+
rel: 'noopener noreferrer',
|
|
199
|
+
label: 'Terms of Service',
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
}}
|
|
203
|
+
>
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Notes:
|
|
207
|
+
|
|
208
|
+
* Omitting a key (for example `termsOfService`) hides that link.
|
|
209
|
+
* `label` overrides the translated text for that single link.
|
|
210
|
+
* Use `_self` for internal pages and `_blank` + `rel="noopener noreferrer"` for external pages.
|
|
211
|
+
* Control which of the configured links render in each component via the component's `legalLinks` prop.
|
|
212
|
+
|
|
213
|
+
## Overrides
|
|
214
|
+
|
|
215
|
+
`overrides` lets you force location/language signals instead of browser or network detection.
|
|
216
|
+
This is useful for QA, local development, and preview environments.
|
|
217
|
+
|
|
218
|
+
```tsx
|
|
219
|
+
<ConsentManagerProvider
|
|
220
|
+
options={{
|
|
221
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
222
|
+
overrides: {
|
|
223
|
+
country: 'DE',
|
|
224
|
+
region: 'BY',
|
|
225
|
+
language: 'de-DE',
|
|
226
|
+
},
|
|
227
|
+
}}
|
|
228
|
+
>
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
You can also override Global Privacy Control (GPC) behavior during testing:
|
|
232
|
+
|
|
233
|
+
```tsx
|
|
234
|
+
<ConsentManagerProvider
|
|
235
|
+
options={{
|
|
236
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
237
|
+
overrides: {
|
|
238
|
+
gpc: true,
|
|
239
|
+
},
|
|
240
|
+
}}
|
|
241
|
+
>
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
> ⚠️ **Warning:**
|
|
245
|
+
> Treat overrides as an environment/testing tool. Avoid hard-coding production overrides unless that behavior is intentional for your deployment.
|
|
246
|
+
|
|
247
|
+
## Policy Packs
|
|
248
|
+
|
|
249
|
+
In hosted mode (recommended), the backend resolves the correct policy automatically — no frontend policy config needed:
|
|
250
|
+
|
|
251
|
+
```tsx
|
|
252
|
+
<ConsentManagerProvider
|
|
253
|
+
options={{
|
|
254
|
+
backendURL: 'https://your-instance.c15t.dev',
|
|
255
|
+
}}
|
|
256
|
+
>
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Fallback: Offline Policies
|
|
260
|
+
|
|
261
|
+
When no backend is available, `ConsentManagerProvider` accepts `offlinePolicy.policyPacks` for local policy resolution during development, testing, previews, or temporary backend outages:
|
|
262
|
+
|
|
263
|
+
```tsx
|
|
264
|
+
<ConsentManagerProvider
|
|
265
|
+
options={{
|
|
266
|
+
mode: 'offline',
|
|
267
|
+
offlinePolicy: {
|
|
268
|
+
i18n: {
|
|
269
|
+
defaultProfile: 'default',
|
|
270
|
+
messages: {
|
|
271
|
+
default: {
|
|
272
|
+
translations: {
|
|
273
|
+
en: { cookieBanner: { title: 'Privacy choices' } },
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
qc: {
|
|
277
|
+
fallbackLanguage: 'fr',
|
|
278
|
+
translations: {
|
|
279
|
+
en: { cookieBanner: { title: 'Quebec Privacy Settings' } },
|
|
280
|
+
fr: { cookieBanner: { title: 'Paramètres de confidentialité du Québec' } },
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
policyPacks: [
|
|
286
|
+
{
|
|
287
|
+
id: 'qc_opt_in',
|
|
288
|
+
match: { regions: [{ country: 'CA', region: 'QC' }] },
|
|
289
|
+
i18n: { messageProfile: 'qc' },
|
|
290
|
+
consent: { model: 'opt-in', expiryDays: 365 },
|
|
291
|
+
ui: { mode: 'banner' },
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
id: 'default_world',
|
|
295
|
+
match: { isDefault: true },
|
|
296
|
+
consent: { model: 'none' },
|
|
297
|
+
ui: { mode: 'none' },
|
|
298
|
+
},
|
|
299
|
+
],
|
|
300
|
+
},
|
|
301
|
+
overrides: {
|
|
302
|
+
country: 'CA',
|
|
303
|
+
region: 'QC',
|
|
304
|
+
},
|
|
305
|
+
}}
|
|
306
|
+
>
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Notes:
|
|
310
|
+
|
|
311
|
+
* `offlinePolicy` is only used in `offline` mode.
|
|
312
|
+
* Treat offline policies as a development/testing tool or resilience fallback, not the primary production source of truth.
|
|
313
|
+
* `offlinePolicy.i18n` lets offline mode mirror hosted `messageProfile` and profile-local `fallbackLanguage` behavior.
|
|
314
|
+
* Omitting `offlinePolicy.policyPacks` uses the built-in synthetic opt-in fallback banner. Hosted network fallback uses the same opt-in banner.
|
|
315
|
+
* `offlinePolicy: { policyPacks: [] }` is explicit no-banner mode.
|
|
316
|
+
* In hosted mode, backend `policyPacks` remain the source of truth — frontend offline policies never override a live backend decision.
|
|
317
|
+
|
|
318
|
+
Read the full guide at [Policy Packs](/docs/frameworks/react/policy-packs) and the conceptual model at [Policy Packs Concept](/docs/frameworks/react/concepts/policy-packs).
|
|
319
|
+
|
|
320
|
+
## Props
|
|
321
|
+
|
|
322
|
+
|Property|Value|
|
|
323
|
+
|:--|:--|
|
|
324
|
+
|Type Name|\`ConsentManagerProviderProps\`|
|
|
325
|
+
|Source Path|\`./packages/react/src/types/consent-manager.ts\`|
|
|
326
|
+
|
|
327
|
+
\*ExtractedTypeTable: Could not extract "ConsentManagerProviderProps" from "./packages/react/src/types/consent-manager.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: ConsentWidget
|
|
3
|
-
description: An inline consent management widget for embedding in settings or
|
|
3
|
+
description: An inline consent management widget for embedding in settings or
|
|
4
|
+
privacy pages. Shows category toggles with accordion layout.
|
|
5
|
+
group: frameworks
|
|
4
6
|
---
|
|
5
7
|
`ConsentWidget` is a standalone, inline consent management widget. Unlike `ConsentDialog` (which is a modal), the widget embeds directly in your page layout - ideal for privacy settings pages, account preferences, or any page where users should be able to manage consent without a modal overlay.
|
|
6
8
|
|
|
@@ -128,9 +130,9 @@ If the stock widget structure is already correct, stay with tokens and slots ins
|
|
|
128
130
|
|
|
129
131
|
## Props
|
|
130
132
|
|
|
131
|
-
|
|
133
|
+
|Property|Value|
|
|
134
|
+
|:--|:--|
|
|
135
|
+
|Type Name|\`ConsentWidgetProps\`|
|
|
136
|
+
|Source Path|\`./packages/react/src/components/consent-widget/types.ts\`|
|
|
132
137
|
|
|
133
|
-
|
|
134
|
-
|:--|:--|:--|:--|:--:|
|
|
135
|
-
|hideBranding|boolean \|undefined|Controls whether to hide the branding in the widget footer.|-|Optional|
|
|
136
|
-
|legalLinks|(keyof LegalLinksTranslations)\[] \|null \|undefined|Controls which legal links to display in the widget footer.|-|Optional|
|
|
138
|
+
\*ExtractedTypeTable: Could not extract "ConsentWidgetProps" from "./packages/react/src/components/consent-widget/types.ts" using base path "/home/runner/work/c15t/c15t". Verify the path/name and that the file is included by your tsconfig.\*
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: DevTools
|
|
3
|
-
description: A development tool for inspecting consent state, geolocation,
|
|
3
|
+
description: A development tool for inspecting consent state, geolocation,
|
|
4
|
+
loaded scripts, and consent events in real time.
|
|
5
|
+
group: frameworks
|
|
4
6
|
---
|
|
5
7
|
`DevTools` is a floating panel that shows the internal state of the consent manager. Use it during development to inspect consent values, geolocation results, loaded scripts, and debug consent flows. Also exported as `C15TDevTools` if you need to avoid naming conflicts with other devtools.
|
|
6
8
|
|
|
7
|
-
>
|
|
9
|
+
> ⚠️ **Warning:**
|
|
8
10
|
> DevTools should only be included in development builds. The component renders nothing to the React tree - it injects directly into document.body.
|
|
9
11
|
|
|
10
12
|
## Installation
|
|
@@ -89,8 +91,9 @@ export function AppDevtools() {
|
|
|
89
91
|
|
|
90
92
|
## Props
|
|
91
93
|
|
|
92
|
-
|
|
94
|
+
|Property|Value|
|
|
95
|
+
|:--|:--|
|
|
96
|
+
|Type Name|\`C15TDevToolsProps\`|
|
|
97
|
+
|Source Path|\`./packages/dev-tools/src/react.ts\`|
|
|
93
98
|
|
|
94
|
-
|
|
95
|
-
|:--|:--|:--|:--|:--:|
|
|
96
|
-
|disabled|boolean \|undefined|Whether the DevTools should be disabled Useful for production builds|false|Optional|
|
|
99
|
+
\*ExtractedTypeTable: Could not extract "C15TDevToolsProps" from "./packages/dev-tools/src/react.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: Frame
|
|
3
|
-
description: A consent-gated content wrapper - children only mount when the
|
|
3
|
+
description: A consent-gated content wrapper - children only mount when the
|
|
4
|
+
required consent category is granted.
|
|
5
|
+
group: frameworks
|
|
4
6
|
---
|
|
5
7
|
`Frame` conditionally renders its children based on consent state. When consent for the specified category is not granted, a placeholder is shown instead. Children are not mounted at all until consent is given, preventing any network requests or script execution.
|
|
6
8
|
|
|
@@ -62,12 +64,9 @@ When `Frame` mounts, it automatically adds its `category` to the active `consent
|
|
|
62
64
|
|
|
63
65
|
## Props
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
|Property|Value|
|
|
68
|
+
|:--|:--|
|
|
69
|
+
|Type Name|\`FrameProps\`|
|
|
70
|
+
|Source Path|\`./packages/react/src/components/frame/types.ts\`|
|
|
66
71
|
|
|
67
|
-
|
|
68
|
-
|:--|:--|:--|:--|:--:|
|
|
69
|
-
|children|ReactNode|Content rendered when consent is granted. Children are not mounted until consent is given, preventing unnecessary network requests.|-|✅ Required|
|
|
70
|
-
|category|AllConsentNames|Consent category required to render children.|-|✅ Required|
|
|
71
|
-
|placeholder|ReactNode|A custom placeholder component to display when consent is not met. If not provided, a default placeholder will be displayed.|-|Optional|
|
|
72
|
-
|noStyle|boolean \|undefined|When true, removes all default styling from the component|false|Optional|
|
|
73
|
-
|theme|any|Custom theme to override default styles while maintaining structure and accessibility. Merges with defaults. Ignored when \`noStyle=\{true}\`.|undefined|Optional|
|
|
72
|
+
\*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,6 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Client Modes
|
|
3
|
-
description: Choose how c15t connects to its backend - full hosted integration,
|
|
3
|
+
description: Choose how c15t connects to its backend - full hosted integration,
|
|
4
|
+
offline-only, or bring your own backend.
|
|
5
|
+
group: frameworks
|
|
4
6
|
---
|
|
5
7
|
c15t supports three client modes that determine how consent data is stored and synchronized. Choose the mode that matches your infrastructure:
|
|
6
8
|
|
|
@@ -8,7 +10,7 @@ c15t supports three client modes that determine how consent data is stored and s
|
|
|
8
10
|
* **Offline mode** - Browser-only storage with no network requests. Best for local development, demos, static deployments, or controlled fallback scenarios.
|
|
9
11
|
* **Custom mode** - Bring your own backend with custom endpoint handlers
|
|
10
12
|
|
|
11
|
-
>
|
|
13
|
+
> ⚠️ **Warning:**
|
|
12
14
|
> If you need durable consent records, server-side enforcement, or automatic jurisdiction detection, use hosted mode. Offline mode cannot provide those guarantees because consent lives only in the browser.
|
|
13
15
|
|
|
14
16
|
<span id="c15t-mode" />
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Consent Categories
|
|
3
3
|
description: How c15t organizes tracking technologies into five consent categories.
|
|
4
|
+
group: frameworks
|
|
4
5
|
---
|
|
5
6
|
c15t organizes tracking technologies into five consent categories that align with GDPR and ePrivacy Directive requirements. Rather than asking users to approve or deny individual cookies or scripts, each category groups related tracking purposes together so users can make meaningful, informed choices about how their data is used.
|
|
6
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Cookie Management
|
|
3
3
|
description: How c15t manages cookies through script, iframe, and network gating
|
|
4
|
-
|
|
4
|
+
group: frameworks
|
|
5
5
|
---
|
|
6
6
|
Cookie management is the most commonly misunderstood part of consent. A critical distinction: **c15t does not manage all cookies on your site.** It controls what scripts, iframes, and network requests are allowed to load - and those third-party resources are what set most cookies.
|
|
7
7
|
|
|
@@ -23,7 +23,7 @@ YouTube embeds, social media widgets, and other iframes can set cookies via thei
|
|
|
23
23
|
**4. Network requests**
|
|
24
24
|
Server responses can include `Set-Cookie` headers. If your page makes requests to third-party APIs or CDNs, those responses may set cookies. c15t's network blocker can intercept `fetch` and `XMLHttpRequest` calls to prevent these requests from happening without consent.
|
|
25
25
|
|
|
26
|
-
>
|
|
26
|
+
> ⚠️ **Warning:**
|
|
27
27
|
> Don't list these cookies in your banner. The cookie names above (\_ga, \_gid, \_fbp, \_fbc) are implementation details — they matter for developers understanding how tracking works, but they should not be exposed to end users in your consent UI. Users don't know what \_ga means, and listing it doesn't help them make an informed choice. Instead, use purpose-based consent categories like "measurement" or "marketing" that communicate why data is collected, not how it is stored.
|
|
28
28
|
|
|
29
29
|
## Why Revoking Consent Requires a Page Reload
|
|
@@ -76,7 +76,7 @@ function ConsentManager({ children }: { children: ReactNode }) {
|
|
|
76
76
|
> ℹ️ **Info:**
|
|
77
77
|
> The reload and deferred sync are part of the broader initialization flow. See Initialization Flow for the full sequence.
|
|
78
78
|
>
|
|
79
|
-
>
|
|
79
|
+
> ⚠️ **Warning:**
|
|
80
80
|
> Setting reloadOnConsentRevoked: false means previously-loaded scripts will continue running after consent is revoked. Only disable this if you have a specific strategy for handling script cleanup.
|
|
81
81
|
|
|
82
82
|
## The Revocation Flow
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Initialization Flow
|
|
3
3
|
description: What happens from provider mount to first render — the full consent lifecycle.
|
|
4
|
+
group: frameworks
|
|
4
5
|
---
|
|
5
6
|
When the consent provider mounts, it creates a cached consent runtime, reads any stored consent from the browser, fetches the resolved policy from the backend (or uses SSR/offline data), and decides whether to show the banner. This entire sequence completes before the first meaningful consent-aware render.
|
|
6
7
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Policy Packs
|
|
3
3
|
description: How c15t resolves regional consent policies and what a policy pack controls.
|
|
4
|
+
group: frameworks
|
|
4
5
|
---
|
|
5
6
|
Different countries need different consent experiences. Policy packs let you define those rules once — c15t picks the right one automatically based on where the visitor is.
|
|
6
7
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Headless Mode
|
|
3
|
-
description: Build fully custom consent UI using only hooks - no pre-built
|
|
3
|
+
description: Build fully custom consent UI using only hooks - no pre-built
|
|
4
|
+
components required.
|
|
5
|
+
group: frameworks
|
|
4
6
|
---
|
|
5
7
|
c15t's headless mode means using the hooks (`useConsentManager`, `useTranslations`, etc.) without any pre-built UI components. This gives you complete control over the consent experience.
|
|
6
8
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: useColorScheme
|
|
3
3
|
description: Manage light/dark mode preferences for consent components.
|
|
4
|
+
group: frameworks
|
|
4
5
|
---
|
|
5
6
|
`useColorScheme()` manages the color scheme preference for c15t components. It sets up the appropriate CSS class and media query listeners.
|
|
6
7
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Checking Consent
|
|
3
|
-
description: Use has() for flexible consent checks with AND, OR, and NOT logic.
|
|
3
|
+
description: Use has() for flexible consent checks with AND, OR, and NOT logic.
|
|
4
|
+
Check if any consent exists with hasConsented().
|
|
5
|
+
group: frameworks
|
|
4
6
|
---
|
|
5
7
|
## has(condition)
|
|
6
8
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Location Info
|
|
3
|
-
description: Access detected jurisdiction, country, and region. Override
|
|
3
|
+
description: Access detected jurisdiction, country, and region. Override
|
|
4
|
+
geolocation for testing.
|
|
5
|
+
group: frameworks
|
|
4
6
|
---
|
|
5
7
|
## locationInfo
|
|
6
8
|
|