Skip to main content
Instead of fetching cookie data at runtime, you can pre-fetch it during your build step and pass it as static data. This eliminates the client-side network request entirely.

Configuration file

Create a katla.config.mjs (ESM) or katla.config.js (CJS) in your project root to set defaults for katla pull:
CLI flags always override config file values.

CLI

With a config file, katla pull works without arguments:
Or pass the site ID directly:
This fetches your site’s cookie data (per-locale), policies for all locales, and the guard script, then saves them to the .katla/ directory. Add it to your build pipeline:
Then import the JSON and pass it to your provider:
When initialCookies is provided, useKatlaCookies() returns the data immediately — no runtime fetch.

Output structure

The manifest.json file contains an index of all generated files:

Using the guard script locally

The pulled guard.js file can be inlined instead of fetching from the CDN at runtime. Pass it as the guardScript prop: Vite (raw import):
Next.js (read at build time):
When guardScript is provided, the SDK injects the script content inline instead of adding a <script src="..."> tag pointing to the CDN.

CLI reference

The site-id is optional when a katla.config.mjs or katla.config.js file provides it.

Programmatic API

You can also use fetchStaticAll directly in build scripts or server-side code:
For single-file fetching, fetchStaticCookies and fetchStaticPolicy are still available:
See the React guide and Next.js guide for full usage examples.

Examples

Vite static example

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

Next.js static example

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