Docs
Functions

createKizlo

Create a Kizlo server, the client, request handler, and router for your app.

createKizlo builds your Kizlo server from credentials and registered extensions. It returns the handler you mount on a route, a server-to-server client, the resolved router, and the context. Call it once and export the pieces you need.

Parameters

createKizlo(options?)

Every field is optional. Anything you omit falls back to an environment variable, so a credentials-only setup can be driven entirely from .env with no arguments.

Prop

Type

Each field lists its environment fallback above. When a field is omitted and its env var is also missing, Kizlo throws MISSING_ENV_VARIABLE.

extensions takes the extensions whose namespaces are mounted on the client and whose routes and event handlers are mounted on the handler. adapters supplies the auth, captcha, geo, logger, and cookies services.

Returns

A Kizlo instance with four members:

MemberDescription
handler(request: Request) => Promise<Response>, the fetch handler to mount on your server route. It is pre-bound, so destructuring keeps it working.
clientA server-to-server client for calling your own procedures from server code.
routerThe resolved router (core routes plus every registered extension and the webhook route).
contextThe shared server context passed to procedures and middleware.

Examples

Zero-config, everything from .env:

src/lib/kizlo/server/index.ts
import { createKizlo } from "kizlo"

export const { client, handler } = createKizlo()

With extensions registered:

src/lib/kizlo/server/index.ts
import { createKizlo } from "kizlo"
import { reviews } from "./reviews"

export const { client, handler } = createKizlo({
  extensions: [reviews()],
})

With adapters supplied:

src/lib/kizlo/server/index.ts
import { createKizlo, consoleLog } from "kizlo"

export const { client, handler } = createKizlo({
  adapters: {
    logger: consoleLog(),
  },
})

On this page