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. Provide the result through an
integration's adapters.geo.
Forward trusted IPs
Registering a geo adapter also forwards its valid ip to WordPress as x-real-ip. Return only an address
your platform verifies; use null when unavailable. There is no separate forwarding option. Existing geo
configurations gain this behavior, including mocks with a non-null IP.
Use geoVercelNext() on Vercel or the Cloudflare integration on Workers.
Cloudflare's geoCloudflare() reads the Worker-entry context without a Next.js headers dependency.
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
This example assumes your trusted ingress sets x-ingress-verified-ip and rejects spoofed values.
import { createGeoAdapter } from "kizlo"
export const geo = createGeoAdapter({
getConnInfo(request) {
return {
ip: request?.headers.get("x-ingress-verified-ip") ?? 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:
import { createIntegration, createKizlo } from "kizlo"
import { geo } from "../adapters/geo"
const platform = createIntegration({ id: "platform", adapters: { geo } })
export const { client, handler } = createKizlo({
integrations: [platform],
})