Store API Overview
Entry Points
getOrCreateConsentRuntime(options)
The recommended entry point. Creates both a consent client and a Zustand vanilla store in one call, with built-in caching — calling it again with the same options returns the same instance.
Returns: { consentManager, consentStore, cacheKey }
consentManager— The low-level client instanceconsentStore— Zustand vanilla store with all state and actionscacheKey— Cache key for this runtime instance
configureConsentManager(options)
Lower-level API that creates only the client (no store). Use this when you need full control over store creation.
createConsentManagerStore(manager, options)
Creates a Zustand vanilla store from a client instance. Accepts all store configuration options.
Legal Links
Configure legal policy URLs in store options via legalLinks:
Notes:
- Omitting a key (for example
termsOfService) hides that link. labeloverrides the translated text for that single link.- Use
_selffor internal pages and_blank+rel="noopener noreferrer"for external pages. - The
c15tpackage is headless; these links are used by your UI layer (custom UI or@c15t/ui-based integrations).
Overrides
Set initial overrides to force location/language signals during runtime initialization:
You can also force Global Privacy Control behavior for testing:
For runtime updates after initialization, call setOverrides().
Info
Treat overrides as an environment/testing tool. Avoid hard-coding production overrides unless that behavior is intentional for your deployment.
Store Patterns
Reading State
Subscribing to Changes
Use subscribe() for UI state and other broad store updates:
Use subscribeToConsentChanges() when you only want real saved preference changes:
Info
Prefer subscribeToConsentChanges() or onConsentChanged for analytics SDKs and consent-mode integrations. Raw consentStore.subscribe() fires for every store update, including UI-only changes.
Window Namespace
The store is also exposed on the window object for debugging and direct access:
The namespace defaults to c15tStore and can be configured via the namespace store option.