Skip to content

consent

@evolve-storefront/consent · v1.0.0

One interface for consent, and an adapter per consent management platform.

Get started

  1. Install the package with the peer dependencies it needs. It comes from the Evolve registry, which needs a one-time sign-in.

    pnpm add @evolve-storefront/consent react
    Requirements1
    react>=19
  2. Wrap your app in ConsentProvider. Setup lists its props.

Then render it on a page:

"use client";
import { createUsercentricsAdapter } from "@evolve-storefront/consent/adapters/usercentrics";
import { ConsentProvider, useConsent } from "@evolve-storefront/consent/provider";
import type { ReactNode } from "react";
// Which Usercentrics services count as which category is decided per tenant.
const adapter = createUsercentricsAdapter({
services: { analytics: ["Wom6s1CtF"], marketing: ["jzMEq56vW"] },
});
export function Providers({ children }: { children: ReactNode }) {
return <ConsentProvider adapter={adapter}>{children}</ConsentProvider>;
}
export function MarketingPixel() {
const { granted } = useConsent();
return granted.marketing ? <script src="https://pixel.example/p.js" async /> : null;
}

Hooks

1 hook to read and change the data yourself, for when you build your own UI. The example above only needs useConsent. All hooks

More in this package