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 asonRequest 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 inc.env.eventContext:
Platform-Specific Notes
- Cloudflare Pages Functions run on the Cloudflare Workers runtime
- Use the
ASSETSbinding to serve static files - The
eventContextprovides access to Pages-specific functionality likewaitUntilandpassThroughOnException - Client IP is extracted from the
cf-connecting-ipheader - Pages Functions support file-based routing in the
functions/directory
Deployment
Cloudflare Pages expects Functions in thefunctions/ directory: