Skip to main content
The Cloudflare Pages adapter provides utilities for running Hono applications on Cloudflare Pages Functions.

Import

Functions

handle()

Converts a Hono application to a Cloudflare Pages Function handler.

Parameters

  • app - The Hono application instance

Returns

A Pages Function that can be exported as onRequest or other Pages Function exports.

Example

handleMiddleware()

Wraps a Hono middleware to work as a Cloudflare Pages Function middleware.

Parameters

  • middleware - Hono middleware handler

Returns

A Pages Function that executes the middleware and passes through to the next function.

Example

serveStatic()

Middleware for serving static files from Cloudflare Pages’ ASSETS binding.
This is for advanced mode. See Cloudflare Pages Functions Advanced Mode.

Example

getConnInfo()

Extracts connection information from the Cloudflare Pages request.

Returns

Example

Types

EventContext

The Cloudflare Pages event context passed to Functions.

Accessing EventContext

The event context is available in c.env.eventContext:

Platform-Specific Notes

  • Cloudflare Pages Functions run on the Cloudflare Workers runtime
  • Use the ASSETS binding to serve static files
  • The eventContext provides access to Pages-specific functionality like waitUntil and passThroughOnException
  • Client IP is extracted from the cf-connecting-ip header
  • Pages Functions support file-based routing in the functions/ directory

Deployment

Cloudflare Pages expects Functions in the functions/ directory:

See Also