Skip to content

honoAdapter

honoAdapter<TEventMap>(router, options): (c) => Promise<Response>

Defined in: hono/src/index.ts:38

Creates a Hono handler for handling webhooks

Hono’s c.req.text() retrieves the raw request body as a string, which is used directly for signature verification.

TEventMap extends Record<string, WebhookEvent>

WebhookRouter<TEventMap>

The WebhookRouter instance

HonoAdapterOptions<TEventMap[keyof TEventMap]>

Adapter options including a verifier function

Hono handler function

(c): Promise<Response>

Context

Promise<Response>

import { Hono } from 'hono';
import { honoAdapter } from '@kotodayori/hono';
import { createStripeVerifier, StripeWebhookRouter } from '@kotodayori/stripe';
const router = new StripeWebhookRouter();
const app = new Hono();
app.post('/webhook', honoAdapter(router, {
verifier: createStripeVerifier(stripe, process.env.STRIPE_WEBHOOK_SECRET!),
}));