---
title: IAB TCF
description: Turn on the IAB TCF 2.4 banner and preference center in a SvelteKit
  app with IABConsentBanner, IABConsentDialog and the provider's iab option.
group: frameworks
lastModified: "2026-10-10T16:01:45+01:00"
---
## Before you turn on IAB TCF

Use IAB TCF when your ad partners require a TC String. It needs an IAB policy
in your Inth project and a CMP ID. IAB Europe assigns a CMP ID to a company
when it registers as a CMP
([register.consensu.org/CMP](https://register.consensu.org/CMP)). Every TC
String names the CMP that wrote it, so an ID you did not register attributes
your visitors' consent to someone else. Example CMP IDs in c15t demos are not
production configuration.

`@c15t/svelte` loads the TCF add-on from `@c15t/iab`, which it installs as a
dependency. The add-on is a separate chunk that apps without IAB never
download.

## Add the IAB components

Turn IAB on with the provider's `iab` prop, keeping your existing mode or `state`,
`scripts` and other props. `registeredCmpId` stands for the number IAB Europe
assigned to your company. The standard and IAB components add their styles
automatically:

```svelte
<!-- Svelte: src/App.svelte -->
<ConsentProvider mode={manifest()} {scripts} iab={{ cmpId: registeredCmpId }}>

<!-- SvelteKit: src/routes/+layout.svelte -->
<ConsentRoot state={data.consent} {scripts} iab={{ cmpId: registeredCmpId }}>
```

Then render `IABConsentBanner` and `IABConsentDialog` next to the standard
components.
The standard components cover visitors whose policy is not IAB, such as those
outside Europe:

```svelte title="src/lib/consent-surfaces.svelte"
<script lang="ts">
	import {
		ConsentBanner,
		ConsentDialog,
		IABConsentBanner,
		IABConsentDialog,
	} from '@c15t/svelte';
</script>

<!-- Visitors whose policy is not IAB get the standard banner and dialog. -->
<ConsentBanner />
<ConsentDialog />
<!-- Visitors under an IAB policy get the TCF banner and preference center. -->
<IABConsentBanner />
<IABConsentDialog />
```

The IAB banner adds its first-paint rules before its elements render. The
IAB dialog adds its rules when it opens, including the base rules it needs
when rendered without a banner. Each sheet appears once per page. On a
server-rendered SvelteKit page, `c15tHandle` writes the rendered components'
rules into `<head>` before hydration.

To run the CSS through Tailwind CSS 3 or put it in a named cascade layer,
set `styles={false}` on the provider and import
`@c15t/svelte/styles.css` followed by `@c15t/svelte/iab/styles.css`.
[Stylesheets and CSS layers](/docs/customization/stylesheets#import-the-stylesheet-yourself)
explains when to use that option.

|`iab` option|Purpose|
|--|--|
|`cmpId`|Your registered CMP ID. A hosted backend can supply it instead.|
|`vendors`|Limit the Global Vendor List to these vendor IDs.|
|`customVendors`|Vendors outside the IAB list, with their purposes and data use.|
|`publisherRestrictions`|Override how vendors may use a purpose. See below.|
|`publisherCountryCode`|Your country, written into the TC String.|
|`gvl`, `gvlURL`|Supply the vendor list, or change where it is fetched from.|
|`enabled`|`false` keeps the configuration but leaves the add-on unmounted.|

Pass `iab={false}`, or omit it, to leave IAB off. If a visitor's policy
then uses the `iab` model and the backend sends its vendor list, the
provider throws an `IABUnavailableError` (code `C15T_IAB_UNAVAILABLE`) while
rendering, on the server and in the browser: the standard banner does not
handle the IAB model, so the visitor would otherwise get no working consent
UI. Set `iab`, or remove the `iab` model from the policy. A backend that
answers `gvl: null` turns IAB off for the request, and the policy runs as
opt-in.

[IABConsentBanner](./components/iab-consent-banner) and
[IABConsentDialog](./components/iab-consent-dialog) list each component's
props.

`IABConsentBanner` and `IABConsentDialog` stay hidden until an IAB policy resolves for the visitor. Forcing the
dialog open does not create a policy or a vendor list, so check the policy
resolution and the vendor list request before changing how they render.

## Read the TCF state

`getConsentManager().iab` holds the live IAB state: the vendor list, purpose
and vendor consents, `isLoadingGVL`, and the actions `acceptAll()`,
`rejectAll()`, `setPurposeConsent()`, `setVendorConsent()`,
`setSpecialFeatureOptIn()` and `save()`. It is `null` when IAB is off.
`getIAB()` returns the same object at the moment you call it.
[Context getters](./getters#read-and-change-iab-tcf-consent) lists every
member.

For a custom IAB banner, `@c15t/svelte/headless` exports
`getIABBannerDisplayItems`, `processGVLData` and `getIABTranslations`.

## Restrict how vendors use a purpose

Pass publisher restrictions in the provider's `iab` option as
`publisherRestrictions`, for example
`[{ purposeId: 4, restrictionType: 0, vendorIds: [10, 755] }]` to stop vendors
10 and 755 using purpose 4. Use vendors from your own list whose declarations
allow each restriction.

Each restriction type has a requirement that depends on the vendor list:

|`restrictionType`|Meaning|Allowed when the vendor|
|--|--|--|
|`0`|Purpose not allowed on any legal basis|declares the purpose for consent or legitimate interest|
|`1`|Consent required|declares the purpose for legitimate interest and lists it in `flexiblePurposes`|
|`2`|Legitimate interest required|declares the purpose for consent and lists it in `flexiblePurposes`|

Type `2` is never allowed for purposes 1, 3, 4, 5 and 6, which TCF allows
only with consent. TCF allows restrictions only in service-specific TC strings.
c15t always writes those, so the deprecated `isServiceSpecific` option has no
effect on restrictions.
c15t copies the restrictions when the CMP starts, so changing your array
afterwards has no effect.

c15t checks restrictions when the vendor list loads and again before each TC
String is encoded. Unsupported restrictions include type `3`, which the spec
reserves, a vendor or purpose missing from the list, and a vendor with two
restriction types for one purpose. They are never dropped. Loading IAB
settings, saving and generating a TC String all reject with a
`PublisherRestrictionError` exported by `@c15t/iab`. On a `createIAB` handle
these are `whenReady()`, `save()` and `generateTCString()`. No TC String is
written and no consent is recorded. Retrying `whenReady()` does not fetch
another vendor list. The error lasts until a new vendor list is set up: with an
explicit `gvl` option that never happens, so saving keeps failing even if the
kernel later holds a different list. When the CMP follows the kernel's list
instead, a replacement list is checked again and saving works once it accepts
the restrictions. When a replacement vendor list makes a restriction
unsupported, c15t also clears the TC authority confirmed under the previous
list, so gated scripts stop until the configuration is fixed. Whenever c15t
withdraws the authority it confirmed, it also removes the TC String from the
`euconsent-v2` cookie and localStorage entry. Because the check reads the
current vendor list, a vendor that stops declaring a purpose or its flexibility
makes a restriction invalid. Narrow a `vendors` allowlist and your restrictions
together.

Saved TC Strings carry the restrictions in their `PubRestrictions` section, and
`__tcfapi('getTCData')` reports them as `publisher.restrictions`, keyed by
purpose ID, then vendor ID. A stored TC String whose restrictions differ from
the current configuration is not restored. If the visitor's stored choice is
otherwise current, the banner opens again, as it does after a policy change,
and closes once the visitor saves. IAB gates that depend on the TC String stay
denied until then. c15t also removes the superseded TC String from the
`euconsent-v2` cookie and localStorage entry, so vendors reading standard
storage do not pick it up. An unchanged configuration restores the stored TC
String without asking.
When reading a string written under TCF policy version 2 or 3, c15t accepts
type `2` for purposes 3 to 6, which those versions allowed. Strings c15t
writes always follow the current policy.

The React, Vue, Svelte and `@c15t/browser/iab` preference centres list each
vendor under the legal basis the restrictions leave it. A vendor whose purpose
now requires legitimate interest gets an objection control instead of a
consent toggle, and a prohibited purpose no longer lists the vendor. A
purpose whose vendors all use legitimate interest has no consent switch,
because turning one off would change nothing the vendors rely on; its
objection control is the opt-out. Such a purpose does not decide its c15t
category: the category follows the purposes in it that the visitor can
consent to. Legitimate interest never grants a category on its own. If none of
a category's purposes has a consent basis, nothing can consent to them, Accept
All included, so the category stays denied. See
[categories under an IAB policy](/docs/concepts/consent-state#categories-under-an-iab-policy).
Stack switches
cover only the purposes some vendor processes on consent. Display-model rows
expose this as `hasConsentBasis`. Custom preference UIs can call
`applyPublisherRestrictionsToGVL` from `@c15t/iab/headless`, or pass
`publisherRestrictions` to `processGVLForDialog`, to get the same vendor
declarations. The configured restrictions are on the kernel's IAB state as
`publisherRestrictions`.

Consent-gated scripts, network rules and iframes with a `vendorId` also apply
the confirmed restrictions for that vendor:

* Type `0` blocks a target that declares the purpose in `iabPurposes` or
  `iabLegIntPurposes`.
* Type `1` makes a purpose declared in `iabLegIntPurposes` require purpose and
  vendor consent. Legitimate interest no longer satisfies it.
* Type `2` makes a purpose declared in `iabPurposes` require purpose and vendor
  legitimate interest. Consent no longer satisfies it.

Types `1` and `2` block the target when the vendor list does not mark the
purpose as flexible for that vendor. Targets without a `vendorId` ignore
restrictions. A target that uses only legitimate interest once restrictions
apply is not blocked by a refused category, since it needs no consent; its
legitimate interest signals and the visitor's objection decide. GPC and strict
scope still block it, and the category stays refused for scripts that depend on
it. Accept All grants the vendor signal a restriction moves a purpose to,
including legitimate interest for a vendor that declares none. Legitimate
interest a restriction introduces applies until the visitor objects: the
preference centres show it as allowed, and saving without touching it encodes
it as allowed. `introducedLegitimateInterest` from `@c15t/iab/headless` lists
those purposes and vendors for custom preference UIs.

## How the preference centre shows features

The stock IAB preference centres in React, Next.js, Vue, Svelte, Astro and the
script tag follow TCF 2.4 and Policies v5.0.b. Special purposes stay in their
locked section with a lock icon, because the visitor cannot object to them.

Features get their own section after the special purposes. It shows the IAB
standard text for features from the Global Vendor List's
`standardTexts.features`. If the list has no standard text, it shows the
`iab.preferenceCenter.features.description` translation. Each feature lists
its name, description, illustrations and the vendors that use it. The section has no switch, lock or vendor toggle, because
TCF forbids showing features next to a control that cannot be disabled.

The feature section follows the theme's spacing and typography tokens.
Its disclosure arrows are decorative and stay out of the accessibility tree.

A custom preference UI gets the same rows from
`resolveIABDialogDisplayModel` in `@c15t/iab/headless`. `essentialRows` holds
the special purposes only. `featureRows` holds the features, with
`locked: false` and `toggle: 'none'`, so render them without a control.
`featuresStandardText` is the standard text, or `null` when you should use the
translation.

Each vendor's privacy policy and legitimate interest links come from its
`urls[]` entry in the Global Vendor List. The stock preference centres pick
the entry for the language the banner shows, then English. A custom UI gets
the same links from `resolveIABVendorUrls(vendor, language)` in
`@c15t/iab/headless`, or from `policyUrl` and `legitimateInterestUrl` on the
vendors `processGVLForDialog` returns when you pass it `language`. Vendor lists
older than GVL v3 have a single `policyUrl` field, which c15t still reads.

## Consent scope

c15t stores TCF choices per site and browser, which the TCF calls
service-specific scope. It does not sync TC strings across devices, and every
TC string it writes has `IsServiceSpecific` set to `1`.

Do not use `/consent/check` or your own account data to skip the TCF banner on
another device. That turns the choice into multi-device scope, which the TCF
requires you to disclose in the first layer, and c15t does not show that
disclosure. The `isServiceSpecific` option is deprecated. c15t ignores it and
logs a warning when you pass `false`.

## Verify the TCF flow

Accept, reject and save purpose and vendor choices, then check in the console
that `__tcfapi('getTCData', 2, console.log)` returns a TC String that matches
what you chose. Reload and confirm it persists. Check the vendors' actual
requests too; a category banner test does not show that the IAB flow works.

## IAB on the server

`loadConsent` and the consent route know about IAB policies. With a
server-resolved IAB policy, the IAB banner can render in the server HTML, and
the browser fetches the Global Vendor List from the route the server names.
Pass `fetchGvl` to `createConsentRoute` to change how the consent route
fetches the vendor list.

Keep [`c15tHandle`](./rendering#resolve-request-context-once-with-c15thandle) in your server hooks. It
reads the rendered IAB components' stylesheet markers and writes the rules
into `<head>`, so the server banner is styled before hydration without a
stylesheet request. The injected styles use the provider's `nonce`, or the
nonce SvelteKit put on its scripts. The browser reuses those styles and
adds the dialog's rules with the same nonce when it opens. See
[Content Security Policy](./content-security-policy#allow-c15ts-style-elements)
for nonce and prerendered-page requirements.
