useConsentManager
useConsentManager() is the primary hook for interacting with the consent system. It returns the complete consent store state and all action methods.
Warning
Must be used within a ConsentManagerProvider. Throws an error if used outside the provider.
State Properties
Warning: ExtractedTypeTable: Could not extract "StoreRuntimeState" from "./packages/core/src/store/type.ts" using base path "/vercel/path0/apps/c15t-docs/.leadtype/c15t". Verify the path/name and that the file is included by your tsconfig.
Action Methods
Warning: ExtractedTypeTable: Could not extract "StoreActions" from "./packages/core/src/store/type.ts" using base path "/vercel/path0/apps/c15t-docs/.leadtype/c15t". Verify the path/name and that the file is included by your tsconfig.
User Identification
You can link a consent subject to your own internal user ID or a non-secret anonymous visitor ID. c15t stores the identifier in the subject row's externalId field. Consent records remain associated with that subject through subjectId, so your backend can find the subject and its related consent records by external ID for GDPR Article 15 exports.
1. Providing the Current User ID
When using Clerk, wait for Clerk to load and prefer its authenticated userId. Before sign-in, you can fall back to a non-secret visitor ID from your application:
Warning
Values passed through options.user are available to client-side JavaScript.
Pass only a non-secret identifier, such as a Clerk userId or an opaque
visitor ID. Never pass a Clerk session token or a value returned by
getToken().
2. Synchronizing Clerk Sign-ins
Use a component inside ConsentManagerProvider to update the current consent subject when Clerk's authentication state changes:
identifyUser() replaces the subject's current externalId; it does not retain the anonymous ID as an alias. Once a visitor is linked to Clerk, clear the previous visitor ID from the application state or storage used by getVisitorId() so it cannot replace the Clerk ID later.
Info
Backend subject identification requires hosted mode (mode: 'hosted'). In
offline mode, identifyUser() cannot update a backend subject. Identifiers
supplied through options.user can still be held in client state and
persisted with locally stored consent, so do not place sensitive values
there.
Key Types
ConsentState
ConsentStateA record mapping consent category names to their boolean values:
ConsentInfo
ConsentInfoMetadata about when and how consent was recorded:
LocationInfo
LocationInfoDetected geographic location from the c15t backend:
Model
ModelThe active consent model:
'opt-in'— Explicit consent required before tracking (GDPR)'opt-out'— Tracking allowed by default, user can opt out (CCPA)'iab'— IAB TCF 2.3 compliance modenull— No jurisdiction detected yet