@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
- React 18 or later
@katla.app/sdkinstalled (see SDK overview)
Setup
Wrap your app withKatlaProvider:
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 underlyingKatlaClient instance for direct API access.
useConsentManager
Headless hook that combines cookie data, consent state, andwindow.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 stablekatla-* class names you can target with your own CSS.
For a fully custom UI, use the
children render prop. The default markup is replaced entirely:
CookieCatalog
Displays your site’s cookies grouped by category. Also unstyled withkatla-* class names.
Customize per-cookie rendering while keeping the grid layout:
Building a consent banner
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: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:Debug mode
Passdebug 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.