createCookiesAdapter
Build a custom cookies adapter for reading and writing cookies.
createCookiesAdapter declares a custom cookies adapter, typed against the CookiesAdapter contract. Kizlo uses it
to read and write cookies for sessions, preview tokens, and the like. Provide the result through an
integration's adapters.cookies.
Reach for this to bridge your framework's cookie store. On Next.js, the integration wires this for you. That setup lives in the adapter guides, not here.
Parameters
createCookiesAdapter(adapter)Prop
Type
The methods are batched (setAll / getAll / deleteAll), so Kizlo applies all cookie changes for a request in
one pass. Each may be sync or async.
Returns
The adapter, unchanged. createCookiesAdapter only attaches the CookiesAdapter type so you get inference and one
documented entry point.
Examples
import { createCookiesAdapter } from "kizlo"
import { cookies } from "../cookie-store"
export const cookiesAdapter = createCookiesAdapter({
getAll() {
return cookies.getAll().map(({ name, value }) => ({ name, value }))
},
setAll(items) {
for (const { name, value, options } of items) cookies.set(name, value, options)
},
deleteAll(items) {
for (const { name, options } of items) cookies.delete(name, options)
},
})Register it:
import { createIntegration, createKizlo } from "kizlo"
import { cookiesAdapter } from "../adapters/cookies"
const frameworkCookies = createIntegration({ id: "framework-cookies", adapters: { cookies: cookiesAdapter } })
export const { client, handler } = createKizlo({
integrations: [frameworkCookies],
})