@c15t/react 3.0.0-alpha.10 → 3.0.0-alpha.11

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 (45) hide show
  1. package/AGENTS.md +1 -0
  2. package/dist/aggregate-components.js +1 -1
  3. package/dist/chunk-warming.js +1 -1
  4. package/dist/components/consent-gate/atoms.js +1 -1
  5. package/dist/components/iab-panel/atoms/root.js +1 -1
  6. package/dist/components/iab-panel/iab-panel.js +1 -1
  7. package/dist/components/iab-prompt/atoms/root.js +1 -1
  8. package/dist/components/iab-prompt/iab-prompt.js +1 -1
  9. package/dist/components/panel/atoms/root.js +1 -1
  10. package/dist/components/panel-trigger/atoms/root.js +1 -1
  11. package/dist/components/panel-trigger/panel-trigger.js +1 -1
  12. package/dist/components/panel-trigger/toolbar-loader.js +2 -0
  13. package/dist/components/preferences/atoms/root.js +1 -1
  14. package/dist/components/prompt/atoms/root.js +1 -1
  15. package/dist/components/shared/surface-styles.js +1 -1
  16. package/dist/devtools.js +1 -1
  17. package/dist/iab-dialog-deferred.js +2 -0
  18. package/dist/iab.js +1 -1
  19. package/dist/utils/deferred-module.js +1 -1
  20. package/dist/version.js +1 -1
  21. package/dist-types/chunk-warming.d.ts +8 -11
  22. package/dist-types/components/panel-trigger/toolbar-loader.d.ts +34 -0
  23. package/dist-types/components/shared/surface-styles.d.ts +26 -2
  24. package/dist-types/iab-dialog-deferred.d.ts +36 -0
  25. package/dist-types/iab.d.ts +2 -1
  26. package/dist-types/version.d.ts +1 -1
  27. package/docs/README.md +1 -0
  28. package/docs/concepts/choose-your-setup.md +5 -2
  29. package/docs/concepts/data-fetching.md +24 -10
  30. package/docs/concepts/modes.md +9 -6
  31. package/docs/frameworks/react/components/consent-banner.md +3 -3
  32. package/docs/frameworks/react/components/consent-dialog.md +3 -3
  33. package/docs/frameworks/react/components/consent-provider.md +12 -9
  34. package/docs/frameworks/react/components.md +3 -3
  35. package/docs/frameworks/react/content-security-policy.md +8 -2
  36. package/docs/frameworks/react/iab.md +19 -0
  37. package/docs/frameworks/react/quickstart.md +25 -79
  38. package/docs/frameworks/react/rendering.md +161 -139
  39. package/docs/frameworks/react/scripts.md +3 -3
  40. package/docs/frameworks/react/troubleshooting.md +17 -16
  41. package/docs/frameworks/react/upgrade-v3.md +5 -4
  42. package/docs/guides/banner-experiments.md +16 -0
  43. package/docs/integrations/overview.md +1 -0
  44. package/docs/integrations/vercel-speed-insights.md +306 -0
  45. package/package.json +7 -7
@@ -0,0 +1,306 @@
1
+ ---
2
+ title: Vercel Speed Insights
3
+ description: Load the Vercel Speed Insights collector only after measurement
4
+ consent with the c15t vercelSpeedInsights helper, drop Web Vitals reports on
5
+ revocation, and check it in DevTools.
6
+ icon: vercel-analytics
7
+ group: integrations
8
+ ---
9
+
10
+ ## Configure Vercel Speed Insights
11
+
12
+ Enable Speed Insights for the project in Vercel. Remove the `SpeedInsights`
13
+ component or `injectSpeedInsights()` call from `@vercel/speed-insights`. The
14
+ collector starts once per page, so a copy loaded outside c15t keeps reporting
15
+ before consent.
16
+
17
+ | Package manager | Command |
18
+ | :-------------- | :------------------------------------- |
19
+ | npm | `npm install @c15t/integrations@alpha` |
20
+ | pnpm | `pnpm add @c15t/integrations@alpha` |
21
+ | yarn | `yarn add @c15t/integrations@alpha` |
22
+ | bun | `bun add @c15t/integrations@alpha` |
23
+
24
+ ```ts title="src/consent-scripts.ts"
25
+ import { vercelSpeedInsights } from '@c15t/integrations/vercel-speed-insights';
26
+
27
+ export const scripts = [vercelSpeedInsights()];
28
+ ```
29
+
30
+ ## Register the scripts
31
+
32
+ Complete your [framework quickstart](https://v3.c15t.com/docs/frameworks) first. Keep its Inth
33
+ endpoint, policy, styles and consent UI. Remove the vendor's original script,
34
+ SDK initializer or tag-manager entry, so the vendor loads only through c15t.
35
+
36
+ The vendor pages put the helper in `src/consent-scripts.ts`. If your framework
37
+ quickstart already has a `scripts` array, such as the one in `c15t.config.ts`
38
+ in the Next.js guide, add the helper to that array instead of creating a
39
+ second file.
40
+ The `scripts` export is a configuration, not an initializer. Add it to the c15t provider you already have, at the registration
41
+ point for your framework below. These are edits to that provider, not a second
42
+ provider.
43
+
44
+ **Next.js**
45
+
46
+ Add the configuration to `scripts` in `c15t.config.ts`, next to
47
+ `next.config.ts`:
48
+
49
+ ```ts title="c15t.config.ts"
50
+ import { defineConsentConfig } from 'c15t/next';
51
+ import { scripts } from './src/consent-scripts';
52
+
53
+ export default defineConsentConfig({ scripts });
54
+ ```
55
+
56
+ Keep the rest of your config, such as `mode` and `routePrefix`, in the
57
+ same call. `ConsentRoot` reads the config in the browser, so the layout
58
+ keeps passing only `state`. App Router, Pages Router and static export all
59
+ read the same file. See
60
+ [Next.js scripts and embeds](https://v3.c15t.com/docs/frameworks/next/scripts).
61
+
62
+ **TanStack Start**
63
+
64
+ Import the configuration into your root route and pass it to the existing
65
+ `ConsentRoot` as a top-level prop. Keep the loader from the
66
+ [TanStack Start quickstart](https://v3.c15t.com/docs/frameworks/tanstack-start/quickstart):
67
+
68
+ ```tsx title="src/routes/__root.tsx"
69
+ import { scripts } from '../consent-scripts';
70
+
71
+ <ConsentRoot state={consent} scripts={scripts}>
72
+ ```
73
+
74
+ Import vendor helpers in the root route module, not in a server function.
75
+ A server function's return value must be serializable, and script
76
+ configurations carry callbacks. See
77
+ [TanStack Start scripts](https://v3.c15t.com/docs/frameworks/tanstack-start/scripts).
78
+
79
+ **React**
80
+
81
+ Add the configuration to the existing `ConsentProvider` options, next to
82
+ `mode`:
83
+
84
+ ```tsx title="src/consent.tsx"
85
+ import { scripts } from './consent-scripts';
86
+
87
+ <ConsentProvider options={{ mode, scripts }}>
88
+ ```
89
+
90
+ `mode` is the `manifest()` value from the
91
+ [React quickstart](../frameworks/react/quickstart.md). Keep the banner,
92
+ dialog and preferences link inside the provider. See
93
+ [React scripts and embeds](../frameworks/react/scripts.md).
94
+
95
+ **Nuxt**
96
+
97
+ Register the scripts under the `c15t` key in `app/app.config.ts`. Adjust the
98
+ relative import to where you created `consent-scripts.ts`:
99
+
100
+ ```ts title="app/app.config.ts"
101
+ import { scripts } from '../src/consent-scripts';
102
+
103
+ export default defineAppConfig({
104
+ c15t: { scripts },
105
+ });
106
+ ```
107
+
108
+ The Nuxt module merges this over its options in `nuxt.config.ts` and starts
109
+ one script loader in the browser after hydration, once it has applied the
110
+ visitor's stored choice and privacy signals. Keep `scripts` out of
111
+ `nuxt.config.ts`, which reaches the browser as JSON and drops the vendor
112
+ callbacks. Write the vendor IDs into `consent-scripts.ts`. See
113
+ [Nuxt scripts and embeds](https://v3.c15t.com/docs/frameworks/nuxt/scripts).
114
+
115
+ **Vue**
116
+
117
+ Pass the scripts to the existing `c15tVue` plugin call in `src/main.ts`:
118
+
119
+ ```ts title="src/main.ts"
120
+ import { c15tVue, manifest } from 'c15t/vue/vue-plugin';
121
+ import { scripts } from './consent-scripts';
122
+
123
+ app.use(c15tVue, {
124
+ mode: manifest(),
125
+ scripts,
126
+ });
127
+ ```
128
+
129
+ Keep your existing `mode` and other options. The plugin starts one
130
+ script loader when the app mounts, after it has applied the visitor's stored
131
+ choice. Do not also call `createScriptLoader` from a component. See
132
+ [Vue scripts and embeds](https://v3.c15t.com/docs/frameworks/vue/scripts).
133
+
134
+ **Astro**
135
+
136
+ Add the scripts to the client entrypoint from the
137
+ [Astro quickstart](https://v3.c15t.com/docs/frameworks/astro/quickstart), `src/c15t.client.ts`,
138
+ which the integration finds on its own. Keep `astro.config.mjs` as it is.
139
+ If the module already exports scripts, combine the two arrays.
140
+
141
+ ```ts title="src/c15t.client.ts"
142
+ import type { C15tClientOptionsExtension } from 'c15t/astro';
143
+ import { scripts } from './consent-scripts';
144
+
145
+ export default { scripts } satisfies C15tClientOptionsExtension;
146
+ ```
147
+
148
+ Vendor helpers contain callbacks, and the integration options in
149
+ `astro.config.mjs` are serialized into the page, so do not put helpers in
150
+ the integration's `scripts` option. The integration passes the client
151
+ entrypoint to the one runtime every page shares, including across
152
+ `ClientRouter` navigation.
153
+
154
+ **Svelte**
155
+
156
+ Import the scripts in the component that owns your existing provider and
157
+ pass them as a top-level prop:
158
+
159
+ ```svelte title="src/App.svelte"
160
+ <script lang="ts">
161
+ import { ConsentProvider, manifest } from '@c15t/svelte';
162
+ import { scripts } from './consent-scripts';
163
+ </script>
164
+
165
+ <ConsentProvider mode={manifest()} {scripts}>
166
+ <!-- Keep your application, consent UI and preferences link here. -->
167
+ </ConsentProvider>
168
+ ```
169
+
170
+ Retain the styles and consent UI from the [Svelte quickstart](https://v3.c15t.com/docs/frameworks/svelte/quickstart).
171
+ The provider owns the loader and disposes it on unmount.
172
+
173
+ **SvelteKit**
174
+
175
+ Add the scripts to the existing `ConsentRoot` in the root layout. Keep the
176
+ handle and the layout load from the [SvelteKit quickstart](https://v3.c15t.com/docs/frameworks/sveltekit/quickstart).
177
+
178
+ ```svelte title="src/routes/+layout.svelte"
179
+ <script lang="ts">
180
+ import { ConsentRoot } from '@c15t/svelte';
181
+ import { scripts } from '../consent-scripts';
182
+
183
+ let { children, data } = $props();
184
+ </script>
185
+
186
+ <ConsentRoot state={data.consent} {scripts}>
187
+ {@render children()}
188
+ <!-- Keep your consent UI and preferences link here. -->
189
+ </ConsentRoot>
190
+ ```
191
+
192
+ Import vendor helpers in the layout component, not in `+layout.server.ts`:
193
+ a server load cannot send functions to the browser. Prerendered, static and
194
+ SPA-mode pages use the same `scripts` prop. If you pass an externally owned
195
+ `runtime` to the provider, register scripts when creating that runtime instead.
196
+
197
+ **HTML**
198
+
199
+ The helpers in `@c15t/integrations` are ES modules that need a bundler. On a
200
+ page that loads the c15t script tag, paste the vendor's own snippet instead
201
+ and keep it inert until its category is allowed:
202
+
203
+ ```html
204
+ <script type="text/plain" data-c15t-category="measurement">
205
+ // The vendor's snippet, unchanged
206
+ </script>
207
+ ```
208
+
209
+ Use the category this guide names for the vendor. c15t runs the snippet
210
+ once that category is allowed, and reloads the page when the visitor
211
+ withdraws it. Helper options on this page, such as `loadMode`, do not apply
212
+ to a pasted snippet. See [HTML scripts](https://v3.c15t.com/docs/frameworks/html/scripts).
213
+
214
+ **JavaScript**
215
+
216
+ Pass the scripts to `init()` from `@c15t/browser`, next to your mode:
217
+
218
+ ```ts
219
+ import { init, manifest } from '@c15t/browser';
220
+ import { scripts } from './consent-scripts';
221
+
222
+ const consent = init({
223
+ mode: manifest(),
224
+ scripts,
225
+ });
226
+ ```
227
+
228
+ Keep the mode from your quickstart. With
229
+ `createConsentRuntime` from `c15t/runtime`, pass `scripts` to it instead.
230
+ A kernel you create yourself needs a loader from
231
+ `c15t/modules/script-loader`. Attach one loader per kernel. See
232
+ [JavaScript scripts](https://v3.c15t.com/docs/frameworks/javascript/scripts).
233
+
234
+ ## Options
235
+
236
+ | Option | Default | Behavior |
237
+ | ------------ | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
238
+ | `dsn` | None | Project DSN for deployments outside Vercel, set as `data-dsn`. Reports go to Vercel's vitals endpoint for that DSN. |
239
+ | `mode` | None | `'development'` loads the debug script. `'auto'` and `'production'` load the production script. The helper does not detect your environment. |
240
+ | `debug` | None | `true` loads `https://va.vercel-scripts.com/v1/speed-insights/script.debug.js`, which logs reports to the console and sends nothing. |
241
+ | `endpoint` | None | Custom vitals endpoint, set as `data-endpoint`. |
242
+ | `scriptUrl` | `https://va.vercel-scripts.com/v1/speed-insights/script.js` | Loader URL override, such as `/_vercel/speed-insights/script.js` on Vercel. Takes precedence over `mode` and `debug`. |
243
+ | `sampleRate` | `1` | Share of page loads that report, from `0` to `1`, set as `data-sample-rate`. Other values throw a `TypeError`. |
244
+ | `beforeSend` | None | Edits or drops a report while measurement is allowed. Return the event, with a changed `url` if needed, or `null` to drop it. |
245
+
246
+ The helper also sets `data-sdkn="c15t"` on the script element. Without `dsn`
247
+ or `endpoint`, the collector posts to `/_vercel/speed-insights/vitals` on your
248
+ own origin, which exists only on Vercel deployments with Speed Insights on.
249
+
250
+ ## Loading and revocation
251
+
252
+ `vercelSpeedInsights` uses the `measurement` category. When measurement becomes
253
+ allowed, the helper defines the `window.siq` queue and a `window.si` stub,
254
+ unless they exist, registers a `beforeSend` callback and loads the script.
255
+
256
+ The collector keeps its listeners after its script element is removed and
257
+ sends queued reports on `pagehide` and navigation. On revocation the helper
258
+ removes the script element and its `beforeSend` callback starts returning
259
+ `null`, so no report is sent, including during the reload c15t runs on
260
+ revocation. A later grant re-adds the script, which does not start a second
261
+ collector, and reports resume. Reports also stop when the provider that owns
262
+ the scripts unmounts.
263
+
264
+ The collector holds one `beforeSend` callback. Pass yours through the
265
+ `beforeSend` option. Calling `window.si('beforeSend', ...)` yourself replaces
266
+ the helper's consent check.
267
+
268
+ Reports only cover page loads after consent. The collector reads buffered
269
+ paint and navigation timings, but interactions before consent are missed. The
270
+ helper does not set `data-route`, so Vercel groups reports by URL rather than
271
+ by route pattern such as `/blog/[slug]`.
272
+
273
+ ## Verify Vercel Speed Insights
274
+
275
+ Filter DevTools Network by `speed-insights`. After you allow measurement,
276
+ `script.js` loads from `va.vercel-scripts.com` with `data-sdkn="c15t"`. Change
277
+ route or switch tabs, and a `POST` to `/_vercel/speed-insights/vitals` follows.
278
+ Automated browsers that set `navigator.webdriver` load the collector but send
279
+ nothing. With `debug` or `mode: 'development'` the reports appear in the
280
+ console instead.
281
+
282
+ Test in a private window with an opt-in policy. Open DevTools Network, disable
283
+ the cache and filter by the vendor's domain:
284
+
285
+ 1. Load the page. No request goes to the vendor before you choose.
286
+ 2. Click Reject, then reload. There is still no vendor request.
287
+ 3. Open Privacy settings and allow the helper's category. The vendor script
288
+ loads without a page reload.
289
+ 4. Turn the category off again and save. c15t reloads the page, and the new
290
+ page makes no vendor request.
291
+
292
+ c15t reloads on revocation because removing a script element does not stop
293
+ code that already ran. The vendor's listeners, timers and queued events stay
294
+ alive until the page unloads. If you set `reloadOnConsentRevoked: false`, stop
295
+ the vendor yourself. Register a callback-only script whose `onConsentChange`
296
+ calls the vendor's opt-out API, as shown in
297
+ [custom integrations](./building-integrations.md), and check the
298
+ permission before each of your own event calls. The reload does not delete
299
+ cookies the vendor already set; see
300
+ [clear on revocation for your framework](./overview.md#vendor-switches-and-cookie-cleanup).
301
+
302
+ The helper sets `vendor` to its script ID, so once you declare that vendor a
303
+ visitor can turn it off inside an allowed category. See
304
+ [vendor consent for your framework](./overview.md#vendor-switches-and-cookie-cleanup). The
305
+ [consent verification guide](../guides/verify-consent.md) covers navigation,
306
+ expiry and hosting checks.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c15t/react",
3
- "version": "3.0.0-alpha.10",
3
+ "version": "3.0.0-alpha.11",
4
4
  "description": "React cookie banner, consent manager, preference center, and headless CMP components with IAB TCF and Consent Mode support.",
5
5
  "keywords": [
6
6
  "ccpa",
@@ -264,16 +264,16 @@
264
264
  "test:watch": "bun prebuild && vitest"
265
265
  },
266
266
  "dependencies": {
267
- "@c15t/core": "3.0.0-alpha.10",
268
- "@c15t/dev-tools": "3.0.0-alpha.10",
269
- "@c15t/iab": "3.0.0-alpha.10",
270
- "@c15t/schema": "3.0.0-alpha.8",
267
+ "@c15t/core": "3.0.0-alpha.11",
268
+ "@c15t/dev-tools": "3.0.0-alpha.11",
269
+ "@c15t/iab": "3.0.0-alpha.11",
270
+ "@c15t/schema": "3.0.0-alpha.9",
271
271
  "@c15t/translations": "3.0.0-alpha.6",
272
- "@c15t/ui": "3.0.0-alpha.10",
272
+ "@c15t/ui": "3.0.0-alpha.11",
273
273
  "@types/google.maps": "3.65.3"
274
274
  },
275
275
  "devDependencies": {
276
- "@c15t/backend": "3.0.0-alpha.10",
276
+ "@c15t/backend": "3.0.0-alpha.11",
277
277
  "@c15t/conformance": "0.0.1",
278
278
  "@c15t/typescript-config": "0.0.1",
279
279
  "@c15t/vitest-config": "1.0.0",