Initialization Flow

What happens from runtime creation to first state update — the full consent lifecycle.

When the consent provider mounts, it creates a cached consent runtime, reads any stored consent from the browser, fetches jurisdiction and translation data (via SSR or API), determines the applicable consent model, and decides whether to show the banner. This entire sequence completes before the first meaningful consent-aware render.

Lifecycle Sequence

  1. Provider mounts — creates (or retrieves from cache) a consent runtime and store
  2. Check stored consent — reads existing consent from cookies / localStorage; if found, the banner stays hidden
  3. Fetch init data — calls the backend GET /init (or uses SSR data) for jurisdiction, location, and translations
  4. Resolve consent model — maps jurisdiction to opt-in, opt-out, iab, or null
  5. Decide banner visibility — shows the banner only if no prior consent exists and a regulation applies
  6. Gating enforced — scripts, iframes, and network requests tagged with a consent category are blocked until that category is granted
  7. User interacts — choices are persisted to storage, synced to the backend, and blocked scripts/iframes load immediately after consent is granted

How It Works

Mount — When the provider renders, it creates (or retrieves from cache) a consent runtime and store. Any existing consent is read from localStorage/cookies immediately. If consent already exists, the banner stays hidden and gating rules apply right away. See Client Modes for how the mode affects runtime creation.

Init — The store fetches jurisdiction, location, and translation data. In c15t mode this calls GET /init on your backend; in offline mode it uses hardcoded defaults. If SSR data was passed to the provider, the network fetch is skipped entirely. See Server-Side Utilities for SSR setup.

Model resolution — The jurisdiction from the init response is mapped to a consent model: opt-in (GDPR and similar), opt-out (CCPA), iab (TCF 2.3), or null (no regulation). For opt-out and null models, all categories are auto-granted — unless a Global Privacy Control signal is detected. See Consent Models for the full jurisdiction-to-model mapping.

Save — When the user interacts with the banner or dialog, their choices are persisted to localStorage/cookies and synced to the backend. Script, iframe, and network gating rules update immediately based on the new consent state. See the Script Loader, Iframe Blocking, and Network Blocker guides for gating details.

Revocation — If a user revokes a previously granted category, the page reloads by default to ensure a clean execution environment. The API sync is deferred to the fresh page load. See Cookie Management for revocation and persistence details.

When Does the Banner Show?

The banner appears when all three conditions are true:

  1. No existing consent — the user has never consented (or their consent was cleared)
  2. A regulation applies — the resolved model is opt-in or iab (not null or opt-out)
  3. Storage is accessible — the browser allows localStorage (not blocked in private mode)

If the model is null (no regulation detected) or opt-out, consents are auto-granted and the banner never appears. See Consent Models for which jurisdictions map to which models.

Debugging the Lifecycle

Use the DevTools panel and callbacks to inspect each step of the initialization flow:

StepDevTools PanelCallbackWhat to check
Init / SSR hydrationLocationonBannerFetchedjurisdiction, countryCode, regionCode populated?
Model resolutionLocationonBannerFetchedmodel value in store matches expected jurisdiction
Banner visibilityConsentsactiveUI in store state; consentInfo null?
Consent saveConsents + EventsonConsentSetpreferences object in callback payload
Script loadingScriptsonConsentSetScript IDs and their load/blocked status
Reload on revocationEventsonBeforeConsentRevocationReloadFires before reload; check localStorage for c15t:pending-consent-sync
Deferred syncEventsonError (if sync fails)After reload, check Events panel for successful API call

Configure callbacks in the runtime options to log lifecycle events: