Docs
Functions

createAuthAdapter

Build a custom auth adapter that resolves the caller's identity.

createAuthAdapter declares a custom auth adapter, typed against the AuthAdapter contract. Kizlo calls it to resolve the session behind a request, the third-party identity independent of any WordPress user. Provide the result through an integration's adapters.auth.

Reach for this when you bring your own session layer. For common providers, use a prebuilt adapter instead. Those live in the adapter guides, not here.

Parameters

createAuthAdapter(adapter)

Prop

Type

getSession returns the resolved session. Its id is the identity provider's own id, never a WordPress user id; email is the one join key Kizlo uses to map the session to a WordPress user:

Prop

Type

Returns

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

Examples

src/lib/kizlo/adapters/auth.ts
import { createAuthAdapter } from "kizlo"
import { getSession } from "../session"

export const auth = createAuthAdapter({
  async getSession(request) {
    const session = await getSession(request)
    if (!session) return null

    return {
      id: session.userId,
      email: session.email,
      firstName: session.firstName,
      lastName: session.lastName,
    }
  },
})

Register it:

src/lib/kizlo/server/index.ts
import { createIntegration, createKizlo } from "kizlo"
import { auth } from "../adapters/auth"

const authentication = createIntegration({ id: "authentication", adapters: { auth } })

export const { client, handler } = createKizlo({
  integrations: [authentication],
})

On this page