Skip to content

@adrianhall/cloudflare-toolkit


@adrianhall/cloudflare-toolkit / lib/hono / notFoundHandler

Function: notFoundHandler()

notFoundHandler(options?): NotFoundHandler

Defined in: src/lib/hono/not-found-handler.ts:63

Create an app.notFound handler that returns an RFC 9457 Problem Details 404 response. This mimics what throwing notFound() (@adrianhall/cloudflare-toolkit/errors) through problemDetailsErrorHandler would produce, without requiring a request to actually throw — app.notFound() is wired independently of app.onError().

Parameters

options?

NotFoundHandlerOptions = {}

Options controlling the type URI and whether instance is auto-populated.

Returns

NotFoundHandler

A Hono NotFoundHandler.

Example

ts
import { Hono } from "hono";
import { notFoundHandler } from "@adrianhall/cloudflare-toolkit/hono";

const app = new Hono();
app.notFound(notFoundHandler());