@katla.app/sdk package gives you programmatic access to your site’s cookie data and consent state. Use it to build custom consent UIs instead of the default widget, or to integrate cookie data into your application.
Prerequisites
- A Katla account with a verified site
- At least one completed scan
- Node.js 18+
Installation
Creating a client
Client methods
getCookies
Returns cookie data for your site, grouped by category.injectGuard
Injects the cookie guard script into the page. The guard interceptsdocument.cookie writes and blocks non-consented cookies.
onConsentChange
Subscribes to consent state changes. The callback fires whenever the visitor updates their preferences.Constants
COOKIE_CATEGORIES
An array of all cookie category strings:Types
Caching
Even without static cookies, the SDK caches intelligently:- Client-side (React):
getCookies()deduplicates in-flight requests. Multiple components mounting simultaneously share a single fetch. - Server-side (Next.js): Use
getCachedCookies()from@katla.app/sdk/next/server— it wraps React’scache()to deduplicate across Server Components in the same render pass.
Next steps
Static cookies
Pre-fetch cookie data at build time to eliminate runtime requests.
React guide
Use the SDK with React hooks and components.
Next.js guide
Integrate the SDK in a Next.js App Router project.