Skip to main content
The @katla.app/sdk/react entry point provides React components and hooks for managing cookies and consent. Use it with Vite, Create React App, or any client-side React setup.
For Next.js projects, use the Next.js guide instead — it provides a streamlined setup for the App Router.

Prerequisites

Setup

Wrap your app with KatlaProvider:
KatlaProvider includes KatlaGuard and ConsentBridge automatically. To enable Google Consent Mode, pass the googleConsentMode prop:

KatlaProvider props

Hooks

useKatlaCookies

Fetches your site’s cookie data on mount.

useKatlaConsent

Tracks the visitor’s current consent state in real time.

useKatlaClient

Returns the underlying KatlaClient instance for direct API access.

useConsentManager

Headless hook that combines cookie data, consent state, and window.KatlaConsent actions into a single API. Use it to build fully custom consent UIs without boilerplate.
The ManageableCategory type ('personalization' | 'analytics' | 'marketing' | 'security') is also exported for type-safe category handling.

Components

CookieBanner

A ready-to-use consent banner with accept, reject, and per-category customization. The component is unstyled — it renders semantic HTML with stable katla-* class names you can target with your own CSS.
Customize labels and copy:
For a fully custom UI, use the children render prop. The default markup is replaced entirely:
CSS class names for styling the default UI:

CookieCatalog

Displays your site’s cookies grouped by category. Also unstyled with katla-* class names.
Customize per-cookie rendering while keeping the grid layout:
CSS class names: The fastest way to add a consent banner is with the <CookieBanner> component — it handles all the consent logic out of the box. For full control, use the useConsentManager hook or call window.KatlaConsent methods directly.
window.KatlaConsent is provided by the guard script. It becomes available after KatlaGuard mounts and the script loads. The ConsentBridge component handles polling for it and relaying events to React.

Static cookies (build-time)

Use the Katla CLI to fetch cookie data at build time, then pass it as static data — no runtime fetch needed. 1. Add to your build pipeline:
2. Import and pass to the provider:
See the SDK overview for CLI reference and the programmatic API.

Server-side rendering (SSR)

If your framework supports server-side rendering (Remix, Astro, etc.), fetch cookies on the server and pass them to the provider to avoid a client-side network request:
The guard script and consent bridge still run client-side. Only the cookie data fetch is moved to the server.

Debug mode

Pass debug to KatlaProvider to log SDK activity to the browser console:

Full example

A minimal Vite + React app with cookie catalog and consent banner:

Examples

Dynamic fetching

Vite + React app that fetches cookies and policy at runtime.

Build-time static

Vite + React app using katla pull for build-time cookie data.

Custom consent UI

Vite + React app with a fully custom consent UI using useConsentManager.