Docs
Functions

createGeoAdapter

Build a custom geo adapter that describes the caller's connection.

createGeoAdapter declares a custom geo adapter, typed against the GeoAdapter contract. Kizlo calls it to describe the connection (IP, location, and user agent) for the current request. Register the result on createKizlo's adapters.geo.

Reach for this when your platform exposes geo data Kizlo doesn't read out of the box. For Vercel's edge headers, use the prebuilt adapter instead. That one lives in the adapter guides, not here.

Parameters

createGeoAdapter(adapter)

Prop

Type

getConnInfo returns the connection info. Fill in what you know and leave the rest null:

Prop

Type

Returns

The adapter, unchanged. createGeoAdapter only attaches the GeoAdapter type so you get inference and one documented entry point.

Examples

src/lib/kizlo/adapters/geo.ts
import { createGeoAdapter } from "kizlo"

export const geo = createGeoAdapter({
  getConnInfo(request) {
    return {
      ip: request?.headers.get("x-forwarded-for") ?? null,
      country: request?.headers.get("x-geo-country") ?? null,
      city: request?.headers.get("x-geo-city") ?? null,
      state: null,
      postcode: null,
      timezone: null,
      userAgent: request?.headers.get("user-agent") ?? null,
    }
  },
})

Register it:

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

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

On this page