libconsent
Adapters

iubenda

iubenda Cookie Solution, with or without per-purpose consent.

npm i @libconsent/iubenda
import { ConsentProvider } from "@libconsent/core";
import { iubenda } from "@libconsent/iubenda";

<ConsentProvider
  adapter={iubenda({ siteId: 1234567, cookiePolicyId: 89012345 })}
>
  {children}
</ConsentProvider>;

iubenda keeps drawing its own banner. The adapter writes the csConfiguration it needs, chains onto its callbacks and reports the result.

Options

OptionDefault
siteId—Required. From your iubenda dashboard.
cookiePolicyId—Required. The number in your policy URL.
lang"en"Force a language.
configuration—Anything else csConfiguration takes. Merged over the defaults.
autoBlockingfalseAlso load iubenda's auto-blocking script. See below.
src—A different iubenda_cs.js URL.
manualfalseThe script is already on the page.
purposes—Map iubenda's numbered purposes onto categories.

Purposes

Turn on perPurposeConsent and iubenda reports its five purposes separately:

iubenda({
  siteId: 1234567,
  cookiePolicyId: 89012345,
  configuration: { perPurposeConsent: true },
});
1 Strictly necessary                 → essential
2 Basic interactions & functionality → functional
3 Experience enhancement             → functional
4 Measurement                        → analytics
5 Targeting & Advertising            → marketing

Without per-purpose consent

iubenda reports one all-or-nothing answer, and functional, analytics and marketing all follow it together. Nothing breaks — but a user cannot accept analytics while refusing ads, because iubenda was not asked to offer that.

Auto-blocking

autoBlocking: true loads iubenda's script blocker as well. It is off by default because <CookieService> already decides what runs, and two blockers fighting over one tag is a bad afternoon. Turn it on only for scripts that libconsent doesn't gate — third-party markup you don't control, for instance.

Callbacks

iubenda announces changes through config callbacks rather than DOM events. The adapter wraps onReady, onConsentGiven, onConsentRejected, onPreferenceExpressed and friends rather than replacing them, so anything you registered yourself still runs, and the originals are restored when the provider unmounts.

If you set the callbacks yourself, pass them through configuration so the chaining picks them up:

iubenda({
  siteId: 1234567,
  cookiePolicyId: 89012345,
  configuration: {
    callback: { onConsentGiven: () => console.log("thanks") },
  },
});

On this page