@c15t/browser 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 (93) hide show
  1. package/AGENTS.md +64 -0
  2. package/CHANGELOG.md +27 -0
  3. package/README.md +128 -0
  4. package/dist/861.js +1079 -0
  5. package/dist/925.js +649 -0
  6. package/dist/c15t.css +213 -0
  7. package/dist/c15t.devtools.js +1 -0
  8. package/dist/c15t.headless.js +1 -0
  9. package/dist/c15t.iab.css +190 -0
  10. package/dist/c15t.iab.js +221 -0
  11. package/dist/c15t.js +30 -0
  12. package/dist/devtools.js +11 -0
  13. package/dist/headless.js +17 -0
  14. package/dist/iab.js +784 -0
  15. package/dist/index.js +17 -0
  16. package/dist-types/auto-init.d.ts +42 -0
  17. package/dist-types/client.d.ts +51 -0
  18. package/dist-types/deferred.d.ts +13 -0
  19. package/dist-types/devtools.d.ts +32 -0
  20. package/dist-types/entries/cdn-devtools.d.ts +13 -0
  21. package/dist-types/entries/cdn-headless.d.ts +8 -0
  22. package/dist-types/entries/cdn-iab.d.ts +1 -0
  23. package/dist-types/entries/cdn.d.ts +8 -0
  24. package/dist-types/gated-scripts.d.ts +35 -0
  25. package/dist-types/generated/iab-styles.d.ts +144 -0
  26. package/dist-types/generated/styles.d.ts +137 -0
  27. package/dist-types/global.d.ts +112 -0
  28. package/dist-types/headless.d.ts +41 -0
  29. package/dist-types/iab/mount.d.ts +8 -0
  30. package/dist-types/iab/preferences.d.ts +9 -0
  31. package/dist-types/iab/styles.d.ts +2 -0
  32. package/dist-types/iab/surface.d.ts +4 -0
  33. package/dist-types/iab/vendor-disclosures.d.ts +14 -0
  34. package/dist-types/iab.d.ts +20 -0
  35. package/dist-types/index.d.ts +43 -0
  36. package/dist-types/transports/manifest.d.ts +62 -0
  37. package/dist-types/transports/offline.d.ts +18 -0
  38. package/dist-types/types.d.ts +290 -0
  39. package/dist-types/ui/actions.d.ts +29 -0
  40. package/dist-types/ui/banner.d.ts +13 -0
  41. package/dist-types/ui/branding.d.ts +25 -0
  42. package/dist-types/ui/copy.d.ts +28 -0
  43. package/dist-types/ui/dialog.d.ts +14 -0
  44. package/dist-types/ui/dom.d.ts +48 -0
  45. package/dist-types/ui/mount.d.ts +27 -0
  46. package/dist-types/ui/surface.d.ts +43 -0
  47. package/dist-types/ui/trigger.d.ts +14 -0
  48. package/dist-types/ui/widget.d.ts +27 -0
  49. package/dist-types/version.d.ts +1 -0
  50. package/docs/README.md +64 -0
  51. package/docs/frameworks/javascript/script-loader.md +47 -0
  52. package/docs/frameworks/javascript/script-tag.md +375 -0
  53. package/docs/integrations/adobe-analytics.md +294 -0
  54. package/docs/integrations/ahrefs-analytics.md +291 -0
  55. package/docs/integrations/amplitude.md +292 -0
  56. package/docs/integrations/building-integrations.md +47 -0
  57. package/docs/integrations/clearbit.md +291 -0
  58. package/docs/integrations/cloudflare-web-analytics.md +292 -0
  59. package/docs/integrations/crisp.md +294 -0
  60. package/docs/integrations/databuddy.md +311 -0
  61. package/docs/integrations/fathom-analytics.md +293 -0
  62. package/docs/integrations/google-maps.md +384 -0
  63. package/docs/integrations/google-tag-manager.md +306 -0
  64. package/docs/integrations/google-tag.md +305 -0
  65. package/docs/integrations/heap.md +292 -0
  66. package/docs/integrations/hightouch.md +293 -0
  67. package/docs/integrations/hotjar.md +292 -0
  68. package/docs/integrations/intercom.md +285 -0
  69. package/docs/integrations/linkedin-insights.md +291 -0
  70. package/docs/integrations/logrocket.md +293 -0
  71. package/docs/integrations/matomo-analytics.md +316 -0
  72. package/docs/integrations/meta-pixel.md +285 -0
  73. package/docs/integrations/microsoft-clarity.md +292 -0
  74. package/docs/integrations/microsoft-uet.md +291 -0
  75. package/docs/integrations/mixpanel-analytics.md +295 -0
  76. package/docs/integrations/openai-pixel.md +441 -0
  77. package/docs/integrations/overview.md +111 -0
  78. package/docs/integrations/pirsch.md +295 -0
  79. package/docs/integrations/plausible-analytics.md +295 -0
  80. package/docs/integrations/posthog.md +397 -0
  81. package/docs/integrations/promptwatch.md +291 -0
  82. package/docs/integrations/reddit-pixel.md +294 -0
  83. package/docs/integrations/rudderstack.md +328 -0
  84. package/docs/integrations/rybbit-analytics.md +296 -0
  85. package/docs/integrations/segment.md +292 -0
  86. package/docs/integrations/snapchat-pixel.md +293 -0
  87. package/docs/integrations/tiktok-pixel.md +291 -0
  88. package/docs/integrations/umami-analytics.md +295 -0
  89. package/docs/integrations/vercel-analytics.md +293 -0
  90. package/docs/integrations/x-pixel.md +291 -0
  91. package/docs/integrations/youtube.md +405 -0
  92. package/package.json +117 -0
  93. package/readme.json +44 -0
@@ -0,0 +1,316 @@
1
+ ---
2
+ title: Matomo Analytics
3
+ description: Choose gated loading or Matomo consent signaling and configure the
4
+ correct tracker endpoints.
5
+ group: integrations
6
+ ---
7
+
8
+ ## Configure Matomo
9
+
10
+ Use the site ID and base URL from your Matomo installation. This setup waits
11
+ for measurement permission before requesting `matomo.js`.
12
+
13
+ | Package manager | Command |
14
+ | :-------------- | :-------------------------- |
15
+ | npm | `npm install @c15t/scripts` |
16
+ | pnpm | `pnpm add @c15t/scripts` |
17
+ | yarn | `yarn add @c15t/scripts` |
18
+ | bun | `bun add @c15t/scripts` |
19
+
20
+ ```ts title="src/consent-scripts.ts"
21
+ import { matomoAnalytics } from '@c15t/scripts/matomo-analytics';
22
+
23
+ export const scripts = [
24
+ matomoAnalytics({
25
+ siteId: 1,
26
+ matomoUrl: 'https://analytics.example.com',
27
+ }),
28
+ ];
29
+ ```
30
+
31
+ Replace the base URL and site ID. For Matomo Cloud, use
32
+ `cloudId: 'your-site.matomo.cloud'` instead of `matomoUrl`.
33
+
34
+ ## Register the scripts
35
+
36
+ Complete your [framework quickstart](https://c15t.com/docs/frameworks) first. Keep its Inth
37
+ endpoint, policy, styles and consent UI. Remove the vendor's original script,
38
+ SDK initializer or tag-manager entry so c15t owns loading once.
39
+
40
+ The `scripts` export in `src/consent-scripts.ts` is a configuration, not an
41
+ initializer. Add it to your existing consent owner using the registration point
42
+ below. These are partial edits to that owner, not additional providers.
43
+
44
+ **Next.js**
45
+
46
+ Import the configuration into the client boundary from your router guide:
47
+
48
+ ```ts
49
+ import { ConsentRoot } from 'c15t/next';
50
+ import { scripts } from './consent-scripts';
51
+ ```
52
+
53
+ Keep the server-resolved `state` and shared `consentConfig` from your
54
+ router guide. Its manifest, init and save URLs stay in effect. Add
55
+ `scripts` as a top-level prop on the existing root:
56
+
57
+ ```tsx
58
+ <ConsentRoot state={state} config={consentConfig} scripts={scripts}>
59
+ {children}
60
+ </ConsentRoot>
61
+ ```
62
+
63
+ For a Pages Router or static-export setup using `ConsentProvider`, add
64
+ `scripts` to its existing `options` instead. Keep the router-specific setup
65
+ from [Next.js script loading](https://c15t.com/docs/frameworks/next/script-loader).
66
+
67
+ **TanStack Start**
68
+
69
+ In your existing root route component, import the scripts alongside
70
+ `ConsentRoot`. Keep the server loader from the [TanStack Start quickstart](https://c15t.com/docs/frameworks/tanstack-start/quickstart).
71
+
72
+ ```tsx
73
+ import { Outlet } from '@tanstack/react-router';
74
+ import { ConsentRoot } from 'c15t/tanstack-start';
75
+ import { scripts } from '../consent-scripts';
76
+
77
+ function Root() {
78
+ const state = Route.useLoaderData();
79
+ return (
80
+ <ConsentRoot state={state} backendURL={backendURL} initRoute={false} scripts={scripts}>
81
+ <Outlet />
82
+ {/* Keep your consent banner, dialog and preferences link here. */}
83
+ </ConsentRoot>
84
+ );
85
+ }
86
+ ```
87
+
88
+ This edits the existing route. `Route` and `backendURL` come from its setup;
89
+ keep the document shell and head components if they are part of your root.
90
+ `initRoute={false}` keeps the quickstart's direct-backend initialization.
91
+ If your app mounts a consent server route, retain its existing `initRoute`
92
+ instead. Do not return script callbacks from a server function or route loader.
93
+
94
+ **React**
95
+
96
+ Import the scripts into your existing provider component:
97
+
98
+ ```ts
99
+ import { ConsentProvider } from 'c15t/react';
100
+ import { scripts } from './consent-scripts';
101
+ ```
102
+
103
+ Keep the existing options and add `scripts`:
104
+
105
+ ```tsx
106
+ <ConsentProvider options={{ ...consentOptions, scripts }}>
107
+ {children}
108
+ </ConsentProvider>
109
+ ```
110
+
111
+ Here `consentOptions` is your existing configuration, including
112
+ `mode: hosted({ url: backendURL })`. Keep the banner, dialog and preferences
113
+ link inside the provider. See [React script loading](https://c15t.com/docs/frameworks/react/script-loader).
114
+
115
+ **Nuxt**
116
+
117
+ Attach one loader from the root `app.vue`, after the Nuxt module has
118
+ started its browser runtime. This keeps vendor callbacks in application code rather
119
+ than serialized `nuxt.config.ts` runtime configuration.
120
+
121
+ ```vue title="app/app.vue"
122
+ <script setup lang="ts">
123
+ import { onUnmounted } from 'vue';
124
+ import { createScriptLoader } from 'c15t/modules/script-loader';
125
+ import { scripts } from '../src/consent-scripts';
126
+
127
+ const nuxtApp = useNuxtApp();
128
+ const kernel = useConsentKernel();
129
+ let loader: ReturnType<typeof createScriptLoader> | undefined;
130
+
131
+ const removeMountedHook = nuxtApp.hook('app:mounted', () => {
132
+ loader = createScriptLoader({ kernel, scripts });
133
+ });
134
+ onUnmounted(() => {
135
+ removeMountedHook();
136
+ loader?.dispose();
137
+ });
138
+ </script>
139
+
140
+ <template>
141
+ <ConsentRoot />
142
+ <NuxtPage />
143
+ </template>
144
+ ```
145
+
146
+ Merge the setup code into your root and retain its footer and preferences
147
+ link. `useConsentKernel` is auto-imported by the c15t Nuxt module. Adjust the
148
+ relative script import if your `app.vue` is at the project root. This loader
149
+ waits until the module has applied browser persistence and privacy signals,
150
+ then reads the current snapshot and observes future changes. Do not also register these scripts
151
+ in another loader. See the [Nuxt quickstart](https://c15t.com/docs/frameworks/nuxt/quickstart).
152
+
153
+ **Vue**
154
+
155
+ Use the kernel already provided by the Vue plugin. Merge this setup into
156
+ `App.vue`, whose lifetime covers the application:
157
+
158
+ ```vue title="src/App.vue"
159
+ <script setup lang="ts">
160
+ import { onMounted, onUnmounted } from 'vue';
161
+ import { createScriptLoader } from 'c15t/modules/script-loader';
162
+ import { useConsentKernel } from 'c15t/vue/vue-plugin';
163
+ import ConsentRoot from 'c15t/vue/consent-root';
164
+ import { scripts } from './consent-scripts';
165
+
166
+ const kernel = useConsentKernel();
167
+ let loader: ReturnType<typeof createScriptLoader> | undefined;
168
+
169
+ onMounted(() => {
170
+ loader = createScriptLoader({ kernel, scripts });
171
+ });
172
+ onUnmounted(() => loader?.dispose());
173
+ </script>
174
+
175
+ <template>
176
+ <ConsentRoot />
177
+ <main>Your application</main>
178
+ </template>
179
+ ```
180
+
181
+ Keep your existing page content and preferences link. The plugin still owns
182
+ the kernel and persistence; this component owns only the vendor loader.
183
+ Do not register the same scripts in plugin configuration as well. See the
184
+ [Vue quickstart](https://c15t.com/docs/frameworks/vue/quickstart).
185
+
186
+ **Astro**
187
+
188
+ Point the existing Astro integration at a client module. Keep its `mode`,
189
+ `ui` and framework integration from the [Astro quickstart](https://c15t.com/docs/frameworks/astro/quickstart).
190
+ Import `fileURLToPath` in your Astro configuration:
191
+
192
+ ```js title="astro.config.mjs"
193
+ import { fileURLToPath } from 'node:url';
194
+ ```
195
+
196
+ Add this option to the existing `c15t({ ... })` call. Resolve the path from
197
+ the configuration file because Astro injects the import into a virtual module:
198
+
199
+ ```js
200
+ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)),
201
+ ```
202
+
203
+ Export the scripts from that module:
204
+
205
+ ```ts title="src/c15t.client.ts"
206
+ import type { C15tClientOptionsExtension } from '@c15t/astro';
207
+ import { scripts } from './consent-scripts';
208
+
209
+ export default { scripts } satisfies C15tClientOptionsExtension;
210
+ ```
211
+
212
+ The integration passes this extension to its shared browser runtime. Vendor
213
+ helpers contain callbacks, so do not put them in the serialized `scripts`
214
+ option in `astro.config.mjs`. Keep one runtime across consent islands and
215
+ `ClientRouter` navigation.
216
+
217
+ **Svelte**
218
+
219
+ Import the scripts in the component that owns your existing provider and
220
+ pass them as a top-level prop:
221
+
222
+ ```svelte title="src/App.svelte"
223
+ <script lang="ts">
224
+ import { ConsentManagerProvider, hosted } from '@c15t/svelte';
225
+ import { scripts } from './consent-scripts';
226
+
227
+ const backendURL = import.meta.env.VITE_C15T_BACKEND_URL;
228
+ if (!backendURL) throw new Error('Set VITE_C15T_BACKEND_URL');
229
+ const mode = hosted({ url: backendURL });
230
+ </script>
231
+
232
+ <ConsentManagerProvider {mode} {scripts}>
233
+ <!-- Keep your application, consent UI and preferences link here. -->
234
+ </ConsentManagerProvider>
235
+ ```
236
+
237
+ Retain the styles and consent UI from the [Svelte quickstart](https://c15t.com/docs/frameworks/svelte/quickstart).
238
+ The provider owns the loader and disposes it on unmount.
239
+
240
+ **SvelteKit**
241
+
242
+ Add the scripts to the existing root layout provider. Keep the server load
243
+ and its serializable prefetch data from the [SvelteKit quickstart](https://c15t.com/docs/frameworks/sveltekit/quickstart).
244
+
245
+ ```svelte title="src/routes/+layout.svelte"
246
+ <script lang="ts">
247
+ import { ConsentManagerProvider, hosted } from '@c15t/svelte';
248
+ import { scripts } from '../consent-scripts';
249
+
250
+ let { children, data } = $props();
251
+ const mode = hosted({ url: data.backendURL });
252
+ </script>
253
+
254
+ <ConsentManagerProvider {mode} {scripts} prefetch={data.prefetch}>
255
+ {@render children()}
256
+ <!-- Keep your consent UI and preferences link here. -->
257
+ </ConsentManagerProvider>
258
+ ```
259
+
260
+ Import vendor helpers in the layout component, not in `+layout.server.ts`.
261
+ For static hosting, keep your browser-only `mode` setup and omit request
262
+ prefetch; the `scripts` prop stays the same. If you pass an externally owned
263
+ `runtime` to the provider, register scripts when creating that runtime instead.
264
+
265
+ **JavaScript**
266
+
267
+ Attach the loader to your existing kernel before calling
268
+ `kernel.commands.init()`:
269
+
270
+ ```ts
271
+ import { createScriptLoader } from 'c15t/modules/script-loader';
272
+ import { scripts } from './consent-scripts';
273
+
274
+ const loader = createScriptLoader({ kernel, scripts });
275
+ ```
276
+
277
+ Call `loader.dispose()` when that application instance is destroyed.
278
+ `kernel` is the hosted kernel from your quickstart. A provider-owned kernel
279
+ already has a loader; do not attach a second one. See
280
+ [JavaScript script loading](../frameworks/javascript/script-loader.md).
281
+
282
+ ## Choose the loading mode
283
+
284
+ | `defaultConsent` | Initial load | Later changes |
285
+ | ---------------- | --------------------------------------- | ------------------------------------------------------------------------ |
286
+ | Omitted | Waits for measurement permission | Removes the script on revocation; no Matomo consent callback |
287
+ | `'required'` | Loads immediately with `requireConsent` | Signals `setConsentGiven` and `forgetConsentGiven`; keeps the SDK loaded |
288
+ | `'given'` | Loads immediately with an initial grant | Signals later changes; keeps the SDK loaded |
289
+
290
+ Set `defaultConsent: 'required'` only when you intend the SDK to load before
291
+ permission and let Matomo control tracking. Do not select `'given'` to make an
292
+ opt-in setup start tracking before the visitor's choice. Matomo distinguishes
293
+ [tracking consent from cookie consent](https://developer.matomo.org/guides/tracking-consent).
294
+
295
+ With the default gated mode, removing the script does not stop a tracker that
296
+ has already executed. Add a vendor stop strategy if later denial must stop all
297
+ automatic tracking, or deliberately use Matomo's consent-signaling mode.
298
+
299
+ ## Options
300
+
301
+ | Option | Behavior |
302
+ | ------------------------ | ---------------------------------------------------------------------------------- |
303
+ | `siteId` | Defaults to `1`. Use your actual site ID. |
304
+ | `matomoUrl / cloudId` | Base URL or Cloud identifier used to derive `matomo.js` and `matomo.php`. |
305
+ | `trackerUrl / scriptUrl` | Explicit endpoint overrides. Both are required if no base or Cloud ID is supplied. |
306
+ | `trackPageView` | Defaults to `true`. In required-consent mode, page views are queued on grants. |
307
+ | `enableLinkTracking` | Defaults to `false`. |
308
+ | `disableCookies` | Defaults to `false`; cookie disabling does not select a loading mode. |
309
+ | `defaultConsent` | Omitted by default. `'required'` and `'given'` enable consent signaling. |
310
+
311
+ ## Verify the integration
312
+
313
+ Check both the script and collection endpoints, especially with Cloud or proxy
314
+ configuration. Test the chosen mode in a fresh session, grant measurement,
315
+ revoke it, and inspect subsequent events. Check page-view counts during
316
+ navigation and renewed grants. See [consent verification](https://c15t.com/docs/guides/verify-consent).
@@ -0,0 +1,285 @@
1
+ ---
2
+ title: Meta Pixel
3
+ description: Register the Meta Pixel under marketing permission and verify event
4
+ calls after revocation.
5
+ group: integrations
6
+ ---
7
+
8
+ ## Register the pixel
9
+
10
+ | Package manager | Command |
11
+ | :-------------- | :-------------------------- |
12
+ | npm | `npm install @c15t/scripts` |
13
+ | pnpm | `pnpm add @c15t/scripts` |
14
+ | yarn | `yarn add @c15t/scripts` |
15
+ | bun | `bun add @c15t/scripts` |
16
+
17
+ ```ts title="src/consent-scripts.ts"
18
+ import { metaPixel } from '@c15t/scripts/meta-pixel';
19
+
20
+ export const scripts = [metaPixel({ pixelId: '123456789012345' })];
21
+ ```
22
+
23
+ Replace the pixel ID and pass `scripts` to your existing provider or core script
24
+ loader. The helper uses the `marketing` category. Remove the original pixel
25
+ snippet, including a separately installed tracking image or tag-manager entry.
26
+
27
+ ## Register the scripts
28
+
29
+ Complete your [framework quickstart](https://c15t.com/docs/frameworks) first. Keep its Inth
30
+ endpoint, policy, styles and consent UI. Remove the vendor's original script,
31
+ SDK initializer or tag-manager entry so c15t owns loading once.
32
+
33
+ The `scripts` export in `src/consent-scripts.ts` is a configuration, not an
34
+ initializer. Add it to your existing consent owner using the registration point
35
+ below. These are partial edits to that owner, not additional providers.
36
+
37
+ **Next.js**
38
+
39
+ Import the configuration into the client boundary from your router guide:
40
+
41
+ ```ts
42
+ import { ConsentRoot } from 'c15t/next';
43
+ import { scripts } from './consent-scripts';
44
+ ```
45
+
46
+ Keep the server-resolved `state` and shared `consentConfig` from your
47
+ router guide. Its manifest, init and save URLs stay in effect. Add
48
+ `scripts` as a top-level prop on the existing root:
49
+
50
+ ```tsx
51
+ <ConsentRoot state={state} config={consentConfig} scripts={scripts}>
52
+ {children}
53
+ </ConsentRoot>
54
+ ```
55
+
56
+ For a Pages Router or static-export setup using `ConsentProvider`, add
57
+ `scripts` to its existing `options` instead. Keep the router-specific setup
58
+ from [Next.js script loading](https://c15t.com/docs/frameworks/next/script-loader).
59
+
60
+ **TanStack Start**
61
+
62
+ In your existing root route component, import the scripts alongside
63
+ `ConsentRoot`. Keep the server loader from the [TanStack Start quickstart](https://c15t.com/docs/frameworks/tanstack-start/quickstart).
64
+
65
+ ```tsx
66
+ import { Outlet } from '@tanstack/react-router';
67
+ import { ConsentRoot } from 'c15t/tanstack-start';
68
+ import { scripts } from '../consent-scripts';
69
+
70
+ function Root() {
71
+ const state = Route.useLoaderData();
72
+ return (
73
+ <ConsentRoot state={state} backendURL={backendURL} initRoute={false} scripts={scripts}>
74
+ <Outlet />
75
+ {/* Keep your consent banner, dialog and preferences link here. */}
76
+ </ConsentRoot>
77
+ );
78
+ }
79
+ ```
80
+
81
+ This edits the existing route. `Route` and `backendURL` come from its setup;
82
+ keep the document shell and head components if they are part of your root.
83
+ `initRoute={false}` keeps the quickstart's direct-backend initialization.
84
+ If your app mounts a consent server route, retain its existing `initRoute`
85
+ instead. Do not return script callbacks from a server function or route loader.
86
+
87
+ **React**
88
+
89
+ Import the scripts into your existing provider component:
90
+
91
+ ```ts
92
+ import { ConsentProvider } from 'c15t/react';
93
+ import { scripts } from './consent-scripts';
94
+ ```
95
+
96
+ Keep the existing options and add `scripts`:
97
+
98
+ ```tsx
99
+ <ConsentProvider options={{ ...consentOptions, scripts }}>
100
+ {children}
101
+ </ConsentProvider>
102
+ ```
103
+
104
+ Here `consentOptions` is your existing configuration, including
105
+ `mode: hosted({ url: backendURL })`. Keep the banner, dialog and preferences
106
+ link inside the provider. See [React script loading](https://c15t.com/docs/frameworks/react/script-loader).
107
+
108
+ **Nuxt**
109
+
110
+ Attach one loader from the root `app.vue`, after the Nuxt module has
111
+ started its browser runtime. This keeps vendor callbacks in application code rather
112
+ than serialized `nuxt.config.ts` runtime configuration.
113
+
114
+ ```vue title="app/app.vue"
115
+ <script setup lang="ts">
116
+ import { onUnmounted } from 'vue';
117
+ import { createScriptLoader } from 'c15t/modules/script-loader';
118
+ import { scripts } from '../src/consent-scripts';
119
+
120
+ const nuxtApp = useNuxtApp();
121
+ const kernel = useConsentKernel();
122
+ let loader: ReturnType<typeof createScriptLoader> | undefined;
123
+
124
+ const removeMountedHook = nuxtApp.hook('app:mounted', () => {
125
+ loader = createScriptLoader({ kernel, scripts });
126
+ });
127
+ onUnmounted(() => {
128
+ removeMountedHook();
129
+ loader?.dispose();
130
+ });
131
+ </script>
132
+
133
+ <template>
134
+ <ConsentRoot />
135
+ <NuxtPage />
136
+ </template>
137
+ ```
138
+
139
+ Merge the setup code into your root and retain its footer and preferences
140
+ link. `useConsentKernel` is auto-imported by the c15t Nuxt module. Adjust the
141
+ relative script import if your `app.vue` is at the project root. This loader
142
+ waits until the module has applied browser persistence and privacy signals,
143
+ then reads the current snapshot and observes future changes. Do not also register these scripts
144
+ in another loader. See the [Nuxt quickstart](https://c15t.com/docs/frameworks/nuxt/quickstart).
145
+
146
+ **Vue**
147
+
148
+ Use the kernel already provided by the Vue plugin. Merge this setup into
149
+ `App.vue`, whose lifetime covers the application:
150
+
151
+ ```vue title="src/App.vue"
152
+ <script setup lang="ts">
153
+ import { onMounted, onUnmounted } from 'vue';
154
+ import { createScriptLoader } from 'c15t/modules/script-loader';
155
+ import { useConsentKernel } from 'c15t/vue/vue-plugin';
156
+ import ConsentRoot from 'c15t/vue/consent-root';
157
+ import { scripts } from './consent-scripts';
158
+
159
+ const kernel = useConsentKernel();
160
+ let loader: ReturnType<typeof createScriptLoader> | undefined;
161
+
162
+ onMounted(() => {
163
+ loader = createScriptLoader({ kernel, scripts });
164
+ });
165
+ onUnmounted(() => loader?.dispose());
166
+ </script>
167
+
168
+ <template>
169
+ <ConsentRoot />
170
+ <main>Your application</main>
171
+ </template>
172
+ ```
173
+
174
+ Keep your existing page content and preferences link. The plugin still owns
175
+ the kernel and persistence; this component owns only the vendor loader.
176
+ Do not register the same scripts in plugin configuration as well. See the
177
+ [Vue quickstart](https://c15t.com/docs/frameworks/vue/quickstart).
178
+
179
+ **Astro**
180
+
181
+ Point the existing Astro integration at a client module. Keep its `mode`,
182
+ `ui` and framework integration from the [Astro quickstart](https://c15t.com/docs/frameworks/astro/quickstart).
183
+ Import `fileURLToPath` in your Astro configuration:
184
+
185
+ ```js title="astro.config.mjs"
186
+ import { fileURLToPath } from 'node:url';
187
+ ```
188
+
189
+ Add this option to the existing `c15t({ ... })` call. Resolve the path from
190
+ the configuration file because Astro injects the import into a virtual module:
191
+
192
+ ```js
193
+ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)),
194
+ ```
195
+
196
+ Export the scripts from that module:
197
+
198
+ ```ts title="src/c15t.client.ts"
199
+ import type { C15tClientOptionsExtension } from '@c15t/astro';
200
+ import { scripts } from './consent-scripts';
201
+
202
+ export default { scripts } satisfies C15tClientOptionsExtension;
203
+ ```
204
+
205
+ The integration passes this extension to its shared browser runtime. Vendor
206
+ helpers contain callbacks, so do not put them in the serialized `scripts`
207
+ option in `astro.config.mjs`. Keep one runtime across consent islands and
208
+ `ClientRouter` navigation.
209
+
210
+ **Svelte**
211
+
212
+ Import the scripts in the component that owns your existing provider and
213
+ pass them as a top-level prop:
214
+
215
+ ```svelte title="src/App.svelte"
216
+ <script lang="ts">
217
+ import { ConsentManagerProvider, hosted } from '@c15t/svelte';
218
+ import { scripts } from './consent-scripts';
219
+
220
+ const backendURL = import.meta.env.VITE_C15T_BACKEND_URL;
221
+ if (!backendURL) throw new Error('Set VITE_C15T_BACKEND_URL');
222
+ const mode = hosted({ url: backendURL });
223
+ </script>
224
+
225
+ <ConsentManagerProvider {mode} {scripts}>
226
+ <!-- Keep your application, consent UI and preferences link here. -->
227
+ </ConsentManagerProvider>
228
+ ```
229
+
230
+ Retain the styles and consent UI from the [Svelte quickstart](https://c15t.com/docs/frameworks/svelte/quickstart).
231
+ The provider owns the loader and disposes it on unmount.
232
+
233
+ **SvelteKit**
234
+
235
+ Add the scripts to the existing root layout provider. Keep the server load
236
+ and its serializable prefetch data from the [SvelteKit quickstart](https://c15t.com/docs/frameworks/sveltekit/quickstart).
237
+
238
+ ```svelte title="src/routes/+layout.svelte"
239
+ <script lang="ts">
240
+ import { ConsentManagerProvider, hosted } from '@c15t/svelte';
241
+ import { scripts } from '../consent-scripts';
242
+
243
+ let { children, data } = $props();
244
+ const mode = hosted({ url: data.backendURL });
245
+ </script>
246
+
247
+ <ConsentManagerProvider {mode} {scripts} prefetch={data.prefetch}>
248
+ {@render children()}
249
+ <!-- Keep your consent UI and preferences link here. -->
250
+ </ConsentManagerProvider>
251
+ ```
252
+
253
+ Import vendor helpers in the layout component, not in `+layout.server.ts`.
254
+ For static hosting, keep your browser-only `mode` setup and omit request
255
+ prefetch; the `scripts` prop stays the same. If you pass an externally owned
256
+ `runtime` to the provider, register scripts when creating that runtime instead.
257
+
258
+ **JavaScript**
259
+
260
+ Attach the loader to your existing kernel before calling
261
+ `kernel.commands.init()`:
262
+
263
+ ```ts
264
+ import { createScriptLoader } from 'c15t/modules/script-loader';
265
+ import { scripts } from './consent-scripts';
266
+
267
+ const loader = createScriptLoader({ kernel, scripts });
268
+ ```
269
+
270
+ Call `loader.dispose()` when that application instance is destroyed.
271
+ `kernel` is the hosted kernel from your quickstart. A provider-owned kernel
272
+ already has a loader; do not attach a second one. See
273
+ [JavaScript script loading](../frameworks/javascript/script-loader.md).
274
+
275
+ ## Keep event calls behind permission
276
+
277
+ Initialization and later application events are separate responsibilities. If
278
+ application code calls `fbq` directly, check effective marketing permission
279
+ before each optional event and ensure the API is available. Do not assume a
280
+ function still present on `window` means the visitor still permits tracking.
281
+
282
+ For an opt-in policy, verify no pixel script or collection request occurs before
283
+ permission or after rejection. Grant permission, send a test event, revoke and
284
+ confirm future application events stop. Check navigation for duplicate page
285
+ views. See [verification](https://c15t.com/docs/guides/verify-consent).