@c15t/nextjs 2.0.0-rc.1 → 2.0.0-rc.12

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 (98) hide show
  1. package/README.md +10 -3
  2. package/client/components/consent-dialog-link.js +3 -0
  3. package/dist/headless.cjs +1 -1
  4. package/dist/iab/styles.css +12 -0
  5. package/dist/iab/styles.tw3.css +14 -0
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/libs/browser-initial-data.cjs +1 -0
  9. package/dist/libs/browser-initial-data.js +1 -0
  10. package/dist/libs/initial-data.cjs +1 -1
  11. package/dist/libs/initial-data.js +1 -1
  12. package/dist/styles.css +10 -0
  13. package/dist/styles.tw3.css +13 -0
  14. package/dist/types.cjs +1 -1
  15. package/dist/version.cjs +1 -1
  16. package/dist/version.js +1 -1
  17. package/{dist → dist-types}/headless.d.ts +0 -1
  18. package/{dist → dist-types}/index.d.ts +3 -2
  19. package/dist-types/libs/browser-initial-data.d.ts +9 -0
  20. package/{dist → dist-types}/libs/initial-data.d.ts +7 -2
  21. package/dist-types/types.d.ts +38 -0
  22. package/dist-types/version.d.ts +1 -0
  23. package/docs/README.md +73 -0
  24. package/docs/building-headless-components.md +377 -0
  25. package/docs/callbacks.md +184 -0
  26. package/docs/components/consent-banner.md +269 -0
  27. package/docs/components/consent-dialog-link.md +59 -0
  28. package/docs/components/consent-dialog-trigger.md +103 -0
  29. package/docs/components/consent-dialog.md +177 -0
  30. package/docs/components/consent-manager-provider.md +425 -0
  31. package/docs/components/consent-widget.md +133 -0
  32. package/docs/components/dev-tools.md +63 -0
  33. package/docs/components/frame.md +73 -0
  34. package/docs/concepts/client-modes.md +175 -0
  35. package/docs/concepts/consent-categories.md +97 -0
  36. package/docs/concepts/consent-models.md +116 -0
  37. package/docs/concepts/cookie-management.md +122 -0
  38. package/docs/concepts/glossary.md +23 -0
  39. package/docs/concepts/initialization-flow.md +148 -0
  40. package/docs/concepts/policy-packs.md +229 -0
  41. package/docs/headless.md +190 -0
  42. package/docs/hooks/use-color-scheme.md +40 -0
  43. package/docs/hooks/use-consent-manager/checking-consent.md +94 -0
  44. package/docs/hooks/use-consent-manager/location-info.md +95 -0
  45. package/docs/hooks/use-consent-manager/overview.md +420 -0
  46. package/docs/hooks/use-consent-manager/setting-consent.md +92 -0
  47. package/docs/hooks/use-draggable.md +57 -0
  48. package/docs/hooks/use-focus-trap.md +41 -0
  49. package/docs/hooks/use-reduced-motion.md +35 -0
  50. package/docs/hooks/use-ssr-status.md +31 -0
  51. package/docs/hooks/use-text-direction.md +49 -0
  52. package/docs/hooks/use-translations.md +118 -0
  53. package/docs/iab/consent-banner.md +94 -0
  54. package/docs/iab/consent-dialog.md +134 -0
  55. package/docs/iab/overview.md +126 -0
  56. package/docs/iab/use-gvl-data.md +20 -0
  57. package/docs/iframe-blocking.md +107 -0
  58. package/docs/integrations/building-integrations.md +405 -0
  59. package/docs/integrations/databuddy.md +203 -0
  60. package/docs/integrations/google-tag-manager.md +153 -0
  61. package/docs/integrations/google-tag.md +122 -0
  62. package/docs/integrations/linkedin-insights.md +109 -0
  63. package/docs/integrations/meta-pixel.md +342 -0
  64. package/docs/integrations/microsoft-uet.md +112 -0
  65. package/docs/integrations/overview.md +105 -0
  66. package/docs/integrations/posthog.md +199 -0
  67. package/docs/integrations/tiktok-pixel.md +113 -0
  68. package/docs/integrations/x-pixel.md +143 -0
  69. package/docs/internationalization.md +197 -0
  70. package/docs/network-blocker.md +178 -0
  71. package/docs/optimization.md +234 -0
  72. package/docs/policy-packs.md +246 -0
  73. package/docs/quickstart.md +161 -0
  74. package/docs/script-loader.md +321 -0
  75. package/docs/server-side.md +176 -0
  76. package/docs/styling/classnames.md +92 -0
  77. package/docs/styling/color-scheme.md +82 -0
  78. package/docs/styling/css-variables.md +92 -0
  79. package/docs/styling/overview.md +456 -0
  80. package/docs/styling/slots.md +127 -0
  81. package/docs/styling/tailwind.md +113 -0
  82. package/docs/styling/tokens.md +216 -0
  83. package/docs/troubleshooting.md +146 -0
  84. package/iab/styles.css +1 -0
  85. package/package.json +36 -15
  86. package/readme.json +4 -0
  87. package/src/iab/styles.css +12 -0
  88. package/src/iab/styles.tw3.css +14 -0
  89. package/src/styles.css +10 -0
  90. package/src/styles.tw3.css +13 -0
  91. package/styles.css +1 -0
  92. package/dist/headless.d.ts.map +0 -1
  93. package/dist/index.d.ts.map +0 -1
  94. package/dist/libs/initial-data.d.ts.map +0 -1
  95. package/dist/types.d.ts +0 -16
  96. package/dist/types.d.ts.map +0 -1
  97. package/dist/version.d.ts +0 -2
  98. package/dist/version.d.ts.map +0 -1
@@ -0,0 +1,94 @@
1
+ ---
2
+ title: Checking Consent
3
+ description: Use has() for flexible consent checks with AND, OR, and NOT logic. Check if any consent exists with hasConsented().
4
+ ---
5
+ ## has(condition)
6
+
7
+ The `has()` method evaluates whether the current consent state satisfies a condition. It supports simple category checks and complex logical expressions.
8
+
9
+ ### Simple Check
10
+
11
+ ```tsx
12
+ const { has } = useConsentManager();
13
+
14
+ if (has('measurement')) {
15
+ // User has granted measurement consent
16
+ }
17
+ ```
18
+
19
+ ### AND Logic
20
+
21
+ All conditions must be true:
22
+
23
+ ```tsx
24
+ has({ and: ['measurement', 'marketing'] })
25
+ // true only if BOTH measurement AND marketing are granted
26
+ ```
27
+
28
+ ### OR Logic
29
+
30
+ At least one condition must be true:
31
+
32
+ ```tsx
33
+ has({ or: ['measurement', 'marketing'] })
34
+ // true if EITHER measurement OR marketing is granted
35
+ ```
36
+
37
+ ### NOT Logic
38
+
39
+ Negates a condition:
40
+
41
+ ```tsx
42
+ has({ not: 'marketing' })
43
+ // true if marketing consent is NOT granted
44
+ ```
45
+
46
+ ### Nested Conditions
47
+
48
+ Combine operators for complex logic:
49
+
50
+ ```tsx
51
+ has({
52
+ and: [
53
+ 'necessary',
54
+ { or: ['measurement', 'marketing'] },
55
+ { not: 'functionality' },
56
+ ],
57
+ })
58
+ // true if: necessary AND (measurement OR marketing) AND NOT functionality
59
+ ```
60
+
61
+ ### HasCondition Type
62
+
63
+ ```ts
64
+ type HasCondition<CategoryType> =
65
+ | CategoryType // "measurement"
66
+ | { and: HasCondition[] | HasCondition } // { and: ["a", "b"] }
67
+ | { or: HasCondition[] | HasCondition } // { or: ["a", "b"] }
68
+ | { not: HasCondition } // { not: "a" }
69
+ ```
70
+
71
+ ## hasConsented()
72
+
73
+ Returns `true` if the user has made any consent choice (accepted, rejected, or customized). Returns `false` if no consent has been recorded yet.
74
+
75
+ ```tsx
76
+ const { hasConsented } = useConsentManager();
77
+
78
+ if (hasConsented()) {
79
+ // User has previously made a consent choice
80
+ } else {
81
+ // First visit — no consent recorded
82
+ }
83
+ ```
84
+
85
+ ## getDisplayedConsents()
86
+
87
+ Returns the consent types that should be displayed in the UI (based on active `consentCategories` and each type's `display` property):
88
+
89
+ ```tsx
90
+ const { getDisplayedConsents } = useConsentManager();
91
+
92
+ const visibleCategories = getDisplayedConsents();
93
+ // Returns ConsentType[] with name, description, defaultValue, etc.
94
+ ```
@@ -0,0 +1,95 @@
1
+ ---
2
+ title: Location Info
3
+ description: Access detected jurisdiction, country, and region. Override geolocation for testing.
4
+ ---
5
+ ## locationInfo
6
+
7
+ The `locationInfo` state contains the user's detected geographic information:
8
+
9
+ ```tsx
10
+ const { locationInfo } = useConsentManager();
11
+
12
+ if (locationInfo) {
13
+ console.log(locationInfo.jurisdiction); // 'GDPR', 'CCPA', etc.
14
+ console.log(locationInfo.countryCode); // 'DE', 'US', etc.
15
+ console.log(locationInfo.regionCode); // 'BY', 'CA', etc.
16
+ }
17
+ ```
18
+
19
+ `locationInfo` is `null` until the backend responds with geolocation data (or in offline mode if no overrides are set).
20
+
21
+ ## Jurisdiction Codes
22
+
23
+ |Code|Region|Consent Model|
24
+ |--|--|--|
25
+ |`GDPR`|European Union|opt-in|
26
+ |`UK_GDPR`|United Kingdom|opt-in|
27
+ |`CH`|Switzerland|opt-in|
28
+ |`BR`|Brazil (LGPD)|opt-in|
29
+ |`APPI`|Japan|opt-in|
30
+ |`PIPA`|South Korea|opt-in|
31
+ |`PIPEDA`|Canada (excl. Quebec)|opt-out|
32
+ |`QC_LAW25`|Quebec, Canada|opt-in|
33
+ |`CCPA`|California, USA|opt-out|
34
+ |`AU`|Australia|opt-out|
35
+ |`NONE`|No jurisdiction|null model|
36
+
37
+ ## setOverrides()
38
+
39
+ Override detected values for testing or manual configuration. This triggers a re-fetch of consent banner data with the new values:
40
+
41
+ ```tsx
42
+ const { setOverrides } = useConsentManager();
43
+
44
+ // Override country (triggers jurisdiction detection)
45
+ await setOverrides({ country: 'DE' });
46
+
47
+ // Override language
48
+ await setOverrides({ language: 'de' });
49
+
50
+ // Override both
51
+ await setOverrides({ country: 'US', region: 'CA', language: 'es' });
52
+ ```
53
+
54
+ ## setLocationInfo()
55
+
56
+ Directly set location info without triggering a re-fetch:
57
+
58
+ ```tsx
59
+ const { setLocationInfo } = useConsentManager();
60
+
61
+ setLocationInfo({
62
+ jurisdiction: 'GDPR',
63
+ countryCode: 'DE',
64
+ regionCode: 'BY',
65
+ });
66
+ ```
67
+
68
+ ## Testing Different Jurisdictions
69
+
70
+ A development-only component for testing consent behavior across jurisdictions:
71
+
72
+ ```tsx
73
+ function JurisdictionTester() {
74
+ const { setOverrides, model, locationInfo } = useConsentManager();
75
+
76
+ const testCases = [
77
+ { label: 'GDPR', country: 'DE' },
78
+ { label: 'CCPA', country: 'US', region: 'CA' },
79
+ { label: 'PIPEDA', country: 'CA', region: undefined },
80
+ { label: 'QC_LAW25', country: 'CA', region: 'QC' },
81
+ { label: 'NONE', country: 'US', region: 'TX' },
82
+ ];
83
+
84
+ return (
85
+ <div>
86
+ <p>Current: {locationInfo?.jurisdiction ?? 'none'} → model: {model}</p>
87
+ {testCases.map((tc) => (
88
+ <button key={tc.label} onClick={() => setOverrides({ country: tc.country, region: tc.region })}>
89
+ Test as {tc.label}
90
+ </button>
91
+ ))}
92
+ </div>
93
+ );
94
+ }
95
+ ```
@@ -0,0 +1,420 @@
1
+ ---
2
+ title: useConsentManager
3
+ description: The primary hook for accessing consent state and actions. Returns the full consent store including all state properties and action methods.
4
+ ---
5
+ `useConsentManager()` is the primary hook for interacting with the consent system. It returns the complete consent store state and all action methods.
6
+
7
+ ```tsx
8
+ import { useConsentManager } from '@c15t/nextjs';
9
+
10
+ function MyComponent() {
11
+ const {
12
+ consents,
13
+ model,
14
+ has,
15
+ saveConsents,
16
+ // ... all state and actions
17
+ } = useConsentManager();
18
+ }
19
+ ```
20
+
21
+ > ℹ️ **Info:**
22
+ > Must be used within a ConsentManagerProvider. Throws an error if used outside the provider.
23
+
24
+ ## State Properties
25
+
26
+ ### StoreRuntimeState
27
+
28
+ |Property|Type|Description|Default|Required|
29
+ |:--|:--|:--|:--|:--:|
30
+ |branding|"c15t" \|"inth" \|"consent" \|"none"|Whether to show the branding. "consent" is a deprecated alias for "inth".|-|✅ Required|
31
+ |consents|ConsentState|Current consent states for all consent types|-|✅ Required|
32
+ |selectedConsents|ConsentState|Selected consents (Not Saved) - use saveConsents to save|-|✅ Required|
33
+ |consentInfo|ConsentInfo \|null|Information about when and how consent was given|-|✅ Required|
34
+ |activeUI|ActiveUI|Which consent UI component is currently visible.|-|✅ Required|
35
+ |isLoadingConsentInfo|boolean|Whether consent banner information is currently being loaded|-|✅ Required|
36
+ |hasFetchedBanner|boolean|Whether consent banner information has been successfully fetched|-|✅ Required|
37
+ |lastBannerFetchData|Object \|undefined \|null|Last consent banner fetch data for callback replay|-|✅ Required|
38
+ |debug|boolean|Whether debug logging is enabled|-|✅ Required|
39
+ |consentCategories|AllConsentNames|Active consent categories|-|✅ Required|
40
+ |locationInfo|LocationInfo \|null|Subject's location information|-|✅ Required|
41
+ |includeNonDisplayedConsents|boolean|Whether to include non-displayed consents in operations|-|✅ Required|
42
+ |consentTypes|ConsentType|Available consent type configurations|-|✅ Required|
43
+ |iframeBlockerConfig|IframeBlockerConfig|Configuration for the iframe blocker|-|✅ Required|
44
+ |loadedScripts|Record\<string, boolean>|Map of currently loaded script IDs to a boolean loaded-state|-|✅ Required|
45
+ |scriptIdMap|Record\<string, string>|Map of anonymized script IDs to their original IDs|-|✅ Required|
46
+ |model|Model|What type of consent model to use for the consent manager.|-|✅ Required|
47
+ |policyBanner|PolicySurfaceState|Policy-driven UI hints for the consent banner surface.|-|✅ Required|
48
+ |policyDialog|PolicySurfaceState|Policy-driven UI hints for the consent dialog surface.|-|✅ Required|
49
+ |policyCategories|string\[] \|null|Active runtime policy category scope from \`/init\`.|-|✅ Required|
50
+ |policyScopeMode|PolicyScopeMode \|null|Runtime policy scope mode from \`/init\`. Controls whether out-of-scope categories are treated as permissive at runtime.|-|✅ Required|
51
+ |initDataSource|InitDataSource \|null|Source that provided the most recent \`/init\` payload used to hydrate runtime state.|-|✅ Required|
52
+ |initDataSourceDetail|string \|null|Optional source detail for diagnostics (for example, cache header values).|-|✅ Required|
53
+ |iab|IABManager \|null|IAB TCF 2.3 state and actions (null when not configured or not in IAB mode).|-|✅ Required|
54
+ |reloadOnConsentRevoked|boolean|Whether to reload the page when consent is revoked.|-|✅ Required|
55
+ |ssrDataUsed|boolean|Whether SSR data was successfully used for initialization.|-|✅ Required|
56
+ |ssrSkippedReason|SSRSkippedReason|Reason SSR data was skipped, if applicable.|-|✅ Required|
57
+
58
+ #### `consents` ConsentState
59
+
60
+ Current consent states for all consent types
61
+
62
+ |Property|Type|Description|Default|Required|
63
+ |:--|:--|:--|:--|:--:|
64
+ |experience|boolean|-|-|✅ Required|
65
+ |functionality|boolean|-|-|✅ Required|
66
+ |marketing|boolean|-|-|✅ Required|
67
+ |measurement|boolean|-|-|✅ Required|
68
+ |necessary|boolean|-|-|✅ Required|
69
+
70
+ #### `selectedConsents` ConsentState
71
+
72
+ Selected consents (Not Saved) - use saveConsents to save
73
+
74
+ |Property|Type|Description|Default|Required|
75
+ |:--|:--|:--|:--|:--:|
76
+ |experience|boolean|-|-|✅ Required|
77
+ |functionality|boolean|-|-|✅ Required|
78
+ |marketing|boolean|-|-|✅ Required|
79
+ |measurement|boolean|-|-|✅ Required|
80
+ |necessary|boolean|-|-|✅ Required|
81
+
82
+ #### `consentInfo` ConsentInfo
83
+
84
+ Information about when and how consent was given
85
+
86
+ |Property|Type|Description|Default|Required|
87
+ |:--|:--|:--|:--|:--:|
88
+ |time|number|The epoch timestamp of when the consent was recorded|-|✅ Required|
89
+ |subjectId|string \|undefined|The client-generated subject ID in sub\_xxx format|-|Optional|
90
+ |id|string \|undefined|Effective GPC signal used for the request.|-|Optional|
91
+ |externalId|string \|undefined|The external user ID linked to this subject|-|Optional|
92
+ |materialPolicyFingerprint|string \|undefined|Material fingerprint of the active policy when this consent was accepted.|-|Optional|
93
+ |identityProvider|string \|undefined|The identity provider that provided the external ID|-|Optional|
94
+
95
+ #### `locationInfo` LocationInfo
96
+
97
+ Subject's location information
98
+
99
+ |Property|Type|Description|Default|Required|
100
+ |:--|:--|:--|:--|:--:|
101
+ |countryCode|string \|null|ISO country code (e.g., 'US', 'GB', 'DE')|-|✅ Required|
102
+ |regionCode|string \|null|Region or state code within the country (e.g., 'CA', 'ENG')|-|✅ Required|
103
+ |jurisdiction|Object \|null|Jurisdiction code (e.g. 'GDPR')|-|✅ Required|
104
+
105
+ #### `consentTypes` ConsentType
106
+
107
+ Available consent type configurations
108
+
109
+ |Property|Type|Description|Default|Required|
110
+ |:--|:--|:--|:--|:--:|
111
+ |defaultValue|boolean|Whether consent is granted by default|-|✅ Required|
112
+ |description|string|Subject-friendly description of what this consent enables|-|✅ Required|
113
+ |disabled|boolean \|undefined|Whether users can modify this consent setting|-|Optional|
114
+ |display|boolean|Whether to show this consent option in the UI|-|✅ Required|
115
+ |gdprType|number|GDPR category identifier (1-5)|-|✅ Required|
116
+ |name|AllConsentNames|The consent category name|-|✅ Required|
117
+
118
+ #### `iframeBlockerConfig` IframeBlockerConfig
119
+
120
+ Configuration for the iframe blocker
121
+
122
+ |Property|Type|Description|Default|Required|
123
+ |:--|:--|:--|:--|:--:|
124
+ |disableAutomaticBlocking|boolean \|undefined|Whether to disable automatic iframe blocking (defaults to false)|-|Optional|
125
+
126
+ #### `policyBanner` PolicySurfaceState
127
+
128
+ Policy-driven UI hints for the consent banner surface.
129
+
130
+ |Property|Type|Description|Default|Required|
131
+ |:--|:--|:--|:--|:--:|
132
+ |allowedActions|PolicyUiAction \|undefined|Allowed actions for this surface derived from backend runtime policy.|-|Optional|
133
+ |primaryActions|PolicyUiAction \|undefined|Preferred primary action hints from backend runtime policy.|-|Optional|
134
+ |layout|PolicyUiActionGroup \|undefined|Explicit grouped action layout hint from backend runtime policy.|-|Optional|
135
+ |direction|PolicyUiActionDirection \|undefined|Direction hint for the grouped action layout.|-|Optional|
136
+ |uiProfile|PolicyUiProfile \|undefined|Presentation profile hint from backend runtime policy.|-|Optional|
137
+ |scrollLock|boolean \|undefined|Scroll lock hint from backend runtime policy.|-|Optional|
138
+
139
+ #### `policyDialog` PolicySurfaceState
140
+
141
+ Policy-driven UI hints for the consent dialog surface.
142
+
143
+ |Property|Type|Description|Default|Required|
144
+ |:--|:--|:--|:--|:--:|
145
+ |allowedActions|PolicyUiAction \|undefined|Allowed actions for this surface derived from backend runtime policy.|-|Optional|
146
+ |primaryActions|PolicyUiAction \|undefined|Preferred primary action hints from backend runtime policy.|-|Optional|
147
+ |layout|PolicyUiActionGroup \|undefined|Explicit grouped action layout hint from backend runtime policy.|-|Optional|
148
+ |direction|PolicyUiActionDirection \|undefined|Direction hint for the grouped action layout.|-|Optional|
149
+ |uiProfile|PolicyUiProfile \|undefined|Presentation profile hint from backend runtime policy.|-|Optional|
150
+ |scrollLock|boolean \|undefined|Scroll lock hint from backend runtime policy.|-|Optional|
151
+
152
+ #### `iab` IABManager
153
+
154
+ IAB TCF 2.3 state and actions (null when not configured or not in IAB mode).
155
+
156
+ |Property|Type|Description|Default|Required|
157
+ |:--|:--|:--|:--|:--:|
158
+ |config|IABConfig|IAB TCF configuration|-|✅ Required|
159
+ |gvl|Object \|undefined \|null|Global Vendor List data (null when not yet fetched or in non-IAB region)|-|✅ Required|
160
+ |isLoadingGVL|boolean|Whether GVL is currently being fetched|-|✅ Required|
161
+ |nonIABVendors|NonIABVendor|Non-IAB vendors configured by the publisher|-|✅ Required|
162
+ |tcString|string \|null|IAB TCF consent string (TC String)|-|✅ Required|
163
+ |vendorConsents|Record\<string, boolean>|Per-vendor consent state (keyed by vendor ID)|-|✅ Required|
164
+ |vendorLegitimateInterests|Record\<string, boolean>|Per-vendor legitimate interest state|-|✅ Required|
165
+ |purposeConsents|Record\<number, boolean>|Per-purpose consent state (IAB purposes 1-11)|-|✅ Required|
166
+ |purposeLegitimateInterests|Record\<number, boolean>|Per-purpose legitimate interest state|-|✅ Required|
167
+ |specialFeatureOptIns|Record\<number, boolean>|Special feature opt-ins (e.g., precise geolocation)|-|✅ Required|
168
+ |vendorsDisclosed|Record\<number, boolean>|Vendors disclosed to the user in the CMP UI (TCF 2.3 requirement). This tracks which vendors were shown to the user, regardless of whether consent was given. Required for TC String generation.|-|✅ Required|
169
+ |cmpApi|CMPApi \|null|CMP API controls (manages \_\_tcfapi)|-|✅ Required|
170
+ |preferenceCenterTab|"purposes" \|"vendors"|Active tab for the IAB preference center UI|-|✅ Required|
171
+ |setPurposeConsent|(purposeId: number, value: boolean) => void|Sets IAB purpose consent.|-|✅ Required|
172
+ |setPurposeLegitimateInterest|(purposeId: number, value: boolean) => void|Sets IAB purpose legitimate interest.|-|✅ Required|
173
+ |setVendorConsent|(vendorId: string \|number, value: boolean) => void|Sets IAB vendor consent.|-|✅ Required|
174
+ |setVendorLegitimateInterest|(vendorId: string \|number, value: boolean) => void|Sets IAB vendor legitimate interest.|-|✅ Required|
175
+ |setSpecialFeatureOptIn|(featureId: number, value: boolean) => void|Sets special feature opt-in.|-|✅ Required|
176
+ |setPreferenceCenterTab|(tab: "purposes" \|"vendors") => void|Sets the active tab for the IAB preference center.|-|✅ Required|
177
+ |acceptAll|() => void|Accepts all IAB purposes, vendors, and special features.|-|✅ Required|
178
+ |rejectAll|() => void|Rejects all IAB purposes (except necessary/Purpose 1) and vendors.|-|✅ Required|
179
+ |save|() => Promise\<void>|Saves IAB consents and generates TC String.|-|✅ Required|
180
+ |\_updateState|(updates: Partial\<IABState>) => void|Updates IAB state (internal use).|-|✅ Required|
181
+
182
+ ## Action Methods
183
+
184
+ ### StoreActions
185
+
186
+ |Property|Type|Description|Default|Required|
187
+ |:--|:--|:--|:--|:--:|
188
+ |setTranslationConfig|Object|Updates the translation configuration.|-|✅ Required|
189
+ |setOverrides|Object \|undefined \|null|Sets the overrides for the consent manager. Automatically attempts to fetch the consent manager again with the new overrides.|-|✅ Required|
190
+ |setLanguage|Object \|undefined \|null|Set the language override for the consent manager. This will override the language detected from the browser and re-fetch the consent banner information.|-|✅ Required|
191
+ |identifyUser|Object|Identifies the user by setting the external ID.|-|✅ Required|
192
+ |unstable\_acceptPolicyConsent|Object \|undefined|Writes a policy-based consent such as terms and conditions.|-|✅ Required|
193
+ |setSelectedConsent|(name: AllConsentNames, value: boolean) => void|Updates the selected consent state for a specific consent type.|-|✅ Required|
194
+ |saveConsents|Object \|undefined|Saves the user's consent preferences.|-|✅ Required|
195
+ |setConsent|(name: AllConsentNames, value: boolean) => void|Updates the consent state for a specific consent type & automatically save the consent.|-|✅ Required|
196
+ |resetConsents|() => void|Resets all consent preferences to their default values|-|✅ Required|
197
+ |setActiveUI|(ui: ActiveUI, options?: \{ force?: boolean \|undefined; } \|undefined) => void|Sets the active consent UI component.|-|✅ Required|
198
+ |setConsentCategories|(types: AllConsentNames\[]) => void|Updates the active GDPR consent types.|-|✅ Required|
199
+ |setCallback|Object \|undefined|Sets a callback for a specific consent event.|-|✅ Required|
200
+ |subscribeToConsentChanges|Object|Subscribes to change-only consent saves.|-|✅ Required|
201
+ |setLocationInfo|Object \|null|Updates the user's location information.|-|✅ Required|
202
+ |initConsentManager|Object \|undefined \|null|Initializes the consent manager by fetching jurisdiction, location, translations, and branding information.|-|✅ Required|
203
+ |getDisplayedConsents|ConsentType|Retrieves the list of consent types that should be displayed|-|✅ Required|
204
+ |hasConsented|() => boolean|Checks if the user has provided any form of consent|-|✅ Required|
205
+ |has|Object|Evaluates whether current consent state satisfies the given condition.|-|✅ Required|
206
+ |setScripts|Object|Sets multiple script configurations to the store.|-|✅ Required|
207
+ |removeScript|(scriptId: string) => void|Removes a script configuration from the store.|-|✅ Required|
208
+ |updateScripts|Object|Updates scripts based on current consent state. Loads scripts that have consent and aren't loaded yet. Unloads scripts that no longer have consent.|-|✅ Required|
209
+ |isScriptLoaded|(scriptId: string) => boolean|Checks if a script is currently loaded.|-|✅ Required|
210
+ |getLoadedScriptIds|() => string\[]|Gets all currently loaded script IDs.|-|✅ Required|
211
+ |initializeIframeBlocker|() => void|Initializes the iframe blocker instance.|-|✅ Required|
212
+ |updateIframeConsents|() => void|Updates the active consents used by the iframe blocker.|-|✅ Required|
213
+ |destroyIframeBlocker|() => void|Destroys the iframe blocker instance and cleans up resources.|-|✅ Required|
214
+ |initializeNetworkBlocker|() => void|Initializes the network blocker instance.|-|✅ Required|
215
+ |updateNetworkBlockerConsents|() => void|Updates the consent snapshot used by the network blocker.|-|✅ Required|
216
+ |setNetworkBlocker|Object \|undefined|Updates the network blocker configuration at runtime.|-|✅ Required|
217
+ |destroyNetworkBlocker|() => void|Destroys the network blocker instance and cleans up resources.|-|✅ Required|
218
+ |updateConsentCategories|(newCategories: AllConsentNames\[]) => void|Extends the active GDPR consent categories with any categories used by configured scripts.|-|✅ Required|
219
+
220
+ #### `setTranslationConfig`
221
+
222
+ Updates the translation configuration.
223
+
224
+ |Property|Type|Description|Default|Required|
225
+ |:--|:--|:--|:--|:--:|
226
+ |translations|Record\<string, Partial\<Translations>>|-|-|✅ Required|
227
+ |defaultLanguage|string \|undefined|-|-|Optional|
228
+ |disableAutoLanguageSwitch|boolean \|undefined|-|-|Optional|
229
+
230
+ #### `setOverrides`
231
+
232
+ Sets the overrides for the consent manager. Automatically attempts to fetch the consent manager again with the new overrides.
233
+
234
+ |Property|Type|Description|Default|Required|
235
+ |:--|:--|:--|:--|:--:|
236
+ |country|string \|undefined|Country code to forcefully set|-|Optional|
237
+ |region|string \|undefined|Region code to forcefully set|-|Optional|
238
+ |language|string \|undefined|Language code to forcefully set|-|Optional|
239
+ |gpc|boolean \|undefined|Override the Global Privacy Control (GPC) signal. When \`true\`, simulates GPC being active (opt-out of marketing/measurement). When \`false\`, suppresses the real browser GPC signal. When \`undefined\`, falls back to the browser's \`navigator.globalPrivacyControl\`.|-|Optional|
240
+
241
+ #### `identifyUser`
242
+
243
+ Identifies the user by setting the external ID.
244
+
245
+ |Property|Type|Description|Default|Required|
246
+ |:--|:--|:--|:--|:--:|
247
+ |id|string|Usually your own internal ID for the user from your auth provider|-|✅ Required|
248
+ |identityProvider|string \|undefined|The identity provider of the user. Usually the name of the identity provider e.g. 'clerk', 'auth0', 'custom', etc.|-|Optional|
249
+
250
+ #### `unstable_acceptPolicyConsent`
251
+
252
+ Writes a policy-based consent such as terms and conditions.
253
+
254
+ |Property|Type|Description|Default|Required|
255
+ |:--|:--|:--|:--|:--:|
256
+ |type|Object|-|-|✅ Required|
257
+ |domain|string \|undefined|-|-|Optional|
258
+ |givenAt|number \|undefined|-|-|Optional|
259
+ |metadata|Record\<string, unknown> \|undefined|-|-|Optional|
260
+ |preferences|Record\<string, boolean> \|undefined|-|-|Optional|
261
+ |uiSource|string \|undefined|-|-|Optional|
262
+ |externalId|string \|undefined|-|-|Optional|
263
+ |identityProvider|string \|undefined|-|-|Optional|
264
+
265
+ #### `subscribeToConsentChanges`
266
+
267
+ Subscribes to change-only consent saves.
268
+
269
+ |Property|Type|Description|Default|Required|
270
+ |:--|:--|:--|:--|:--:|
271
+ |preferences|ConsentState|-|-|✅ Required|
272
+ |previousPreferences|ConsentState|-|-|✅ Required|
273
+ |allowedCategories|AllConsentNames|-|-|✅ Required|
274
+ |deniedCategories|AllConsentNames|-|-|✅ Required|
275
+ |previousAllowedCategories|AllConsentNames|-|-|✅ Required|
276
+ |previousDeniedCategories|AllConsentNames|-|-|✅ Required|
277
+
278
+ #### `setLocationInfo`
279
+
280
+ Updates the user's location information.
281
+
282
+ |Property|Type|Description|Default|Required|
283
+ |:--|:--|:--|:--|:--:|
284
+ |countryCode|string \|null|ISO country code (e.g., 'US', 'GB', 'DE')|-|✅ Required|
285
+ |regionCode|string \|null|Region or state code within the country (e.g., 'CA', 'ENG')|-|✅ Required|
286
+ |jurisdiction|Object \|null|Jurisdiction code (e.g. 'GDPR')|-|✅ Required|
287
+
288
+ #### `setScripts`
289
+
290
+ Sets multiple script configurations to the store.
291
+
292
+ |Property|Type|Description|Default|Required|
293
+ |:--|:--|:--|:--|:--:|
294
+ |id|string|Unique identifier for the script|-|✅ Required|
295
+ |src|string \|undefined|URL of the script to load|-|Optional|
296
+ |textContent|string \|undefined|Inline JavaScript code to execute|-|Optional|
297
+ |category|HasCondition\<AllConsentNames>|Consent category or condition required to load this script|-|✅ Required|
298
+ |callbackOnly|boolean \|undefined|Whether this is a callback-only script that doesn't need to load an external resource. When true, no script tag will be added to the DOM, only callbacks will be executed.|-|Optional|
299
+ |persistAfterConsentRevoked|boolean \|undefined|Whether the script should persist after consent is revoked.|-|Optional|
300
+ |alwaysLoad|boolean \|undefined|Whether the script should always load regardless of consent state. This is useful for scripts like Google Tag Manager or PostHog that manage their own consent state internally. The script will load immediately and never be unloaded based on consent changes. Note: When using this option, you are responsible for ensuring the script itself respects user consent preferences through its own consent management.|-|Optional|
301
+ |fetchPriority|"high" \|"low" \|"auto" \|undefined|Priority hint for browser resource loading|-|Optional|
302
+ |attributes|Record\<string, string> \|undefined|Additional attributes to add to the script element|-|Optional|
303
+ |async|boolean \|undefined|Whether to use async loading|-|Optional|
304
+ |defer|boolean \|undefined|Whether to defer script loading|-|Optional|
305
+ |nonce|string \|undefined|Content Security Policy nonce|-|Optional|
306
+ |anonymizeId|boolean \|undefined|Whether to use an anonymized ID for the script element, this helps ensure the script is not blocked by ad blockers|-|Optional|
307
+ |target|"head" \|"body" \|undefined|Where to inject the script element in the DOM. Options: \`'head'\`: Scripts are appended to \`\<head>\` (default); \`'body'\`: Scripts are appended to \`\<body>\`|-|Optional|
308
+ |onBeforeLoad|((info: ScriptCallbackInfo) => void) \|undefined|Callback executed before the script is loaded|-|Optional|
309
+ |onLoad|((info: ScriptCallbackInfo) => void) \|undefined|Callback executed when the script loads successfully|-|Optional|
310
+ |onError|((info: ScriptCallbackInfo) => void) \|undefined|Callback executed if the script fails to load|-|Optional|
311
+ |onConsentChange|((info: ScriptCallbackInfo) => void) \|undefined|Callback executed whenever the consent store is changed. This callback only applies to scripts already loaded.|-|Optional|
312
+ |vendorId|string \|number \|undefined|IAB TCF vendor ID - links script to a registered vendor. When in IAB mode, the script will only load if this vendor has consent. Takes precedence over \`category\` when in IAB mode. Use custom vendor IDs (string or number) to gate non-IAB vendors too.|-|Optional|
313
+ |iabPurposes|number\[] \|undefined|IAB TCF purpose IDs this script requires consent for. When in IAB mode and no vendorId is set, the script will only load if ALL specified purposes have consent.|-|Optional|
314
+ |iabLegIntPurposes|number\[] \|undefined|IAB TCF legitimate interest purpose IDs. These purposes can operate under legitimate interest instead of consent. The script loads if all iabPurposes have consent OR all iabLegIntPurposes have legitimate interest established.|-|Optional|
315
+ |iabSpecialFeatures|number\[] \|undefined|IAB TCF special feature IDs this script requires. Options: 1: Use precise geolocation data; 2: Actively scan device characteristics for identification|-|Optional|
316
+
317
+ #### `setNetworkBlocker`
318
+
319
+ Updates the network blocker configuration at runtime.
320
+
321
+ |Property|Type|Description|Default|Required|
322
+ |:--|:--|:--|:--|:--:|
323
+ |enabled|boolean \|undefined|Whether the network blocker is enabled.|-|Optional|
324
+ |initialConsents|ConsentState \|undefined|The consent state snapshot that is currently used for blocking logic.|-|Optional|
325
+ |logBlockedRequests|boolean \|undefined|Whether to automatically log blocked requests to the console.|-|Optional|
326
+ |onRequestBlocked|((info: BlockedRequestInfo) => void) \|undefined|Callback invoked whenever a request is blocked.|-|Optional|
327
+ |rules|NetworkBlockerRule|Domain rules that determine which requests should be blocked.|-|✅ Required|
328
+
329
+ ## identifyUser
330
+
331
+ The `identifyUser()` method links anonymous consent records to an authenticated user. Call it after a user logs in to associate their consent preferences with their account.
332
+
333
+ ```tsx
334
+ import { useConsentManager } from '@c15t/nextjs';
335
+
336
+ function LoginForm() {
337
+ const { identifyUser } = useConsentManager();
338
+
339
+ async function handleLogin(email: string) {
340
+ // ... your login logic
341
+ const user = await api.login(email);
342
+
343
+ // Link consent to the authenticated user
344
+ await identifyUser({
345
+ id: user.id,
346
+ identityProvider: 'your-auth-provider', // e.g. 'clerk', 'auth0'
347
+ });
348
+ }
349
+
350
+ return (
351
+ <form onSubmit={(e) => {
352
+ e.preventDefault();
353
+ handleLogin(new FormData(e.currentTarget).get('email') as string);
354
+ }}>
355
+ <input name="email" type="email" placeholder="Email" />
356
+ <button type="submit">Log in</button>
357
+ </form>
358
+ );
359
+ }
360
+ ```
361
+
362
+ > ℹ️ **Info:**
363
+ > identifyUser sends the user data to the c15t backend. It works in hosted mode, including the legacy alias mode: 'c15t'. In mode: 'offline', the call is a no-op.
364
+
365
+ ## Key Types
366
+
367
+ <details>
368
+ <summary>`ConsentState`</summary>
369
+
370
+ A record mapping consent category names to their boolean values:
371
+
372
+ ```ts
373
+ type ConsentState = Record<AllConsentNames, boolean>;
374
+ // Example: { necessary: true, measurement: true, marketing: false }
375
+ ```
376
+ </details>
377
+
378
+ <details>
379
+ <summary>`ConsentInfo`</summary>
380
+
381
+ Metadata about when and how consent was recorded:
382
+
383
+ ```ts
384
+ interface ConsentInfo {
385
+ time: number; // Epoch timestamp when consent was recorded
386
+ subjectId?: string; // Client-generated subject ID (sub_xxx format)
387
+ externalId?: string; // External user ID linked via identifyUser()
388
+ identityProvider?: string; // Identity provider (e.g. 'clerk', 'auth0')
389
+ }
390
+ ```
391
+ </details>
392
+
393
+ <details>
394
+ <summary>`LocationInfo`</summary>
395
+
396
+ Detected geographic location from the c15t backend:
397
+
398
+ ```ts
399
+ interface LocationInfo {
400
+ countryCode: string; // ISO 3166-1 alpha-2 (e.g. 'DE')
401
+ regionCode: string; // Region/state code (e.g. 'BY')
402
+ jurisdiction: string; // Applicable jurisdiction (e.g. 'GDPR', 'CCPA')
403
+ }
404
+ ```
405
+ </details>
406
+
407
+ <details>
408
+ <summary>`Model`</summary>
409
+
410
+ The active consent model:
411
+
412
+ ```ts
413
+ type Model = 'opt-in' | 'opt-out' | 'iab' | null;
414
+ ```
415
+
416
+ * `'opt-in'` — Explicit consent required before tracking (GDPR)
417
+ * `'opt-out'` — Tracking allowed by default, user can opt out (CCPA)
418
+ * `'iab'` — IAB TCF 2.3 compliance mode
419
+ * `null` — No jurisdiction detected yet
420
+ </details>