Skip to main content
The @katla.app/sdk/next entry point provides a pre-configured provider for Next.js that bundles the guard script injection, consent bridge, and all React hooks into a single "use client" import.

Prerequisites

Setup

1. Add the provider to your root layout

Import KatlaNextProvider directly in your root layout. Because the provider already includes a 'use client' directive, no wrapper file is needed — and children passed from a Server Component remain server-rendered.
KatlaNextProvider includes KatlaGuard and ConsentBridge automatically. To enable Google Consent Mode, pass the googleConsentMode prop:
Pages and components rendered as {children} remain Server Components. The 'use client' boundary only affects the provider itself, not its children.

KatlaNextProvider props

Using hooks

Import hooks directly from @katla.app/sdk/next. They work the same as in the React guide but are re-exported with the "use client" directive already applied.
Available hooks:

Components

All consent UI components are available from @katla.app/sdk/next and work identically to the React versions. They are unstyled and render semantic HTML with stable katla-* class names.

CookieBanner

A ready-to-use consent banner with accept, reject, and per-category customization.
Use the children render prop for a fully custom UI:
See the CookieBanner props and class names reference in the React guide.

CookieCatalog

Displays your site’s cookies grouped by category.
See the CookieCatalog props and class names reference in the React guide. 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 that KatlaNextProvider injects automatically.

Server-side rendering (SSR)

Use getCachedCookies from @katla.app/sdk/next/server to fetch cookies in a Server Component and pass them to the provider. This avoids the client-side network request while keeping data fresh on every request.
When initialCookies is provided, useKatlaCookies() returns the data immediately with loading: false and makes no network request.
getCachedCookies uses React’s cache() to deduplicate requests — even if multiple Server Components call it in the same render, only one fetch is made. It is a server-only import (@katla.app/sdk/next/server). Don’t import it in client components.

Static cookies (build-time)

Use the Katla CLI to fetch cookie data at build time and bundle it as static data — no runtime fetch needed. This is ideal for static sites or when you want the fastest possible page load.

CLI approach

Use the Katla CLI in your build pipeline:
When initialCookies is provided, useKatlaCookies() returns the data immediately with loading: false and makes no network request. getStaticGuardScript() reads the guard script from the .katla/ directory so it can be inlined instead of fetched from the CDN.

Debug mode

Pass debug to KatlaNextProvider to enable console logging:

Full example

A complete Next.js App Router setup with a cookie catalog and consent banner:

Examples

Dynamic SSR

Next.js App Router with server-side cookie fetching via getCachedCookies.

Build-time static

Next.js App Router using katla pull for build-time cookie data.