consentmanager.net
consentmanager.net, with purposes and vendors resolved to names.
bun add @libconsent/consentmanagerimport { consentManager } from "@libconsent/consentmanager";
<ConsentProvider
adapter={consentManager({
codeId: "abc123",
host: "b.delivery.consentmanager.net",
})}
>
{children}
</ConsentProvider>;consentmanager reports consent as numeric purpose and vendor ids. The adapter
resolves those against the CMP's own lists, so you can gate on "analytics" and
on vendor names.
Options
| Option | Default | |
|---|---|---|
codeId | — | Required. The filename in your delivery URL. |
host | — | data-cmp-host. |
cdn | "cdn.consentmanager.net" | data-cmp-cdn. |
autoBlocking | false | Load the auto-blocking build. See below. |
purposes | — | Map purpose names onto categories. |
manual | false | The script is already on the page. |
Purposes
Purpose names are free text, so they are matched on what they reliably contain:
necessary, essential, required, technical → essential
measurement, statistics, analytics, performance → analytics
advertising, marketing, targeting, profiling → marketing
functional, preferences, comfort, convenience → functionalConfiguration-specific names get an explicit mapping:
consentManager({
codeId: "abc123",
purposes: { Reichweitenmessung: "analytics", Werbung: "marketing" },
});An unmapped purpose keeps its own name, so useHasConsent("Social Media")
still answers.
Vendors
libconsent ships with a list of 3000+ officially supported vendors by consentmanager.net so they are automatically recognized. For build-in services we can guarantee that the vendor id is correct, as for others we try to match the name to get the vendor ID.
<CookieService id="hotjar">…</CookieService> {/* → vendor s46 */}If you want to be sure or to gate a service that is not in the list, pass the vendor id(s) explicitly:
<CookieService id="tawk-to" aliases={["s906"]}>
…
</CookieService>Or define custom mappings in the adapter:
consentManager({
codeId: "abc123",
vendors: { "acme-chat": "s1234", "meta-pixel": ["s7", "s2955"] },
});A service mapped to several vendors is granted only if none of them was refused.
Auto-blocking
consentmanager.net has a build-in solution to block scripts before consent is given. However, libconsent disables that by default, since it already gates scripts in React. If you want to use it, pass autoBlocking: true to the adapter:
consentManager({
codeId: "abc123",
autoBlocking: true,
});