---
title: "Runtime Adapters"
description: "Runtime Adapters bridge Hono's Web Standard-based Application Core and Execution Context with platform-specific execution environments, request event structures, bindings, and asset-serving facilit..."
last_updated: "2026-10-12T08:14:12.721744+00:00"
canonical_url: "https://www.doc0.dev/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/technical/runtime-adapters/runtime-adapters"
---

<details>
<summary>Relevant source files</summary>

The following files were used as context for generating this wiki page:

- [src/adapter/cloudflare-pages/handler.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/cloudflare-pages/handler.ts)
- [src/adapter/cloudflare-pages/index.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/cloudflare-pages/index.ts)
- [src/helper/adapter/index.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/helper/adapter/index.ts)
- [src/adapter/lambda-edge/handler.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/lambda-edge/handler.ts)
- [src/adapter/cloudflare-workers/index.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/cloudflare-workers/index.ts)
- [src/context.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/context.ts)
- [src/hono-base.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/hono-base.ts)
- [runtime-tests/workerd/index.ts](https://github.com/blade47/workerd/index.ts)
- [package.json](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/package.json)
- [src/adapter/netlify/handler.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/netlify/handler.ts)
- [src/adapter/service-worker/index.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/service-worker/index.ts)
- [src/middleware/ip-restriction/index.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/middleware/ip-restriction/index.ts)
- [src/adapter/cloudflare-workers/serve-static-module.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/cloudflare-workers/serve-static-module.ts)
- [src/adapter/cloudflare-pages/conninfo.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/cloudflare-pages/conninfo.ts)
- [src/adapter/cloudflare-workers/serve-static.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/cloudflare-workers/serve-static.ts)
- [src/adapter/netlify/index.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/netlify/index.ts)
- [src/adapter/cloudflare-workers/websocket.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/cloudflare-workers/websocket.ts)
- [src/middleware/jsx-renderer/index.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/middleware/jsx-renderer/index.ts)
- [src/adapter/vercel/index.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/vercel/index.ts)
- [src/adapter/bun/serve-static.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/bun/serve-static.ts)
- [src/adapter/service-worker/handler.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/service-worker/handler.ts)
- [src/adapter/bun/index.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/bun/index.ts)
- [src/adapter/lambda-edge/index.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/lambda-edge/index.ts)
- [src/adapter/deno/index.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/deno/index.ts)
- [src/adapter/vercel/handler.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/vercel/handler.ts)
- [src/middleware/serve-static/index.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/middleware/serve-static/index.ts)
- [src/middleware/context-storage/index.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/middleware/context-storage/index.ts)
- [src/adapter/netlify/mod.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/netlify/mod.ts)
- [src/adapter/cloudflare-workers/utils.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/cloudflare-workers/utils.ts)
- [src/adapter/cloudflare-workers/conninfo.ts](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/cloudflare-workers/conninfo.ts)
</details>

## Overview

Runtime Adapters bridge Hono's Web Standard-based [Application Core](https://www.doc0.dev/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/technical/core-engine/application-core) and [Execution Context](https://www.doc0.dev/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/technical/core-engine/execution-context) with platform-specific execution environments, request event structures, bindings, and asset-serving facilities. Different serverless, edge, and worker runtimes utilize disparate native entry points, event signatures, and connection metadata mechanisms that diverge from standard `fetch` event flows. Hono's adapter subsystems translate these proprietary structures into clean Web Standard `Request` and `Response` objects, expose secure connection info, and integrate environment bindings seamlessly.

Sources: [src/adapter/cloudflare-pages/handler.ts:32-46](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/cloudflare-pages/handler.ts#L32-L46)

---

## AWS Lambda Adapters

The AWS Lambda-Edge adapter processes CloudFront edge events (`CloudFrontEdgeEvent`) by mapping incoming CloudFront request structures into a Web Standard `Request` object. When an incoming request carries a query string, host header, or body data (including base64-encoded payloads via `decodeBase64`), `createRequest` reconstructs a full URL and populates request headers.

Sources: [src/adapter/lambda-edge/handler.ts:116-138](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/lambda-edge/handler.ts#L116-L138), [src/adapter/lambda-edge/handler.ts:152-184](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/lambda-edge/handler.ts#L152-L184)

The execution flow transforms responses back into CloudFront-compatible formats through `createResult`. If the response content type indicates binary data according to `isContentTypeBinary`, the body is encoded using `encodeBase64` from array buffers, setting `bodyEncoding: 'base64'`.

```typescript
export const isContentTypeBinary = (contentType: string): boolean => {
  return !/^(text\/(plain|html|css|javascript|csv).*|application\/(.*json|.*xml).*|image\/svg\+xml.*)$/.test(
    contentType
  )
}
```

Sources: [src/adapter/lambda-edge/handler.ts:140-150](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/lambda-edge/handler.ts#L140-L150), [src/adapter/lambda-edge/handler.ts:202-206](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/lambda-edge/handler.ts#L202-L206)

---

## Cloudflare Adapters

Cloudflare runtime adapters support both Cloudflare Workers (`workerd`) and Cloudflare Pages. The Cloudflare Workers adapter exposes module-based static asset handling via `getContentFromKVAsset`, WebSocket upgrading through `upgradeWebSocket`, and remote IP retrieval via `getConnInfo`. Static asset request flows are executed through the call chain `module` (in `serve-static-module.ts`) delegating to `serveStatic` (in `serve-static.ts`), which in turn invokes the base `serveStatic` middleware to resolve MIME types and decode URIs.

```mermaid
sequenceDiagram
    participant Mod as module()
    participant CFSS as serveStatic()
    participant BaseSS as baseServeStatic()

    Mod->>CFSS: serveStatic(options)
    CFSS->>BaseSS: baseServeStatic(options with getContent)
    BaseSS-->>CFSS: Response / Content
    CFSS-->>Mod: MiddlewareHandler Response
```

Sources: [src/adapter/cloudflare-workers/serve-static-module.ts:6-10](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/cloudflare-workers/serve-static-module.ts#L6-L10), [src/adapter/cloudflare-workers/serve-static.ts:21-42](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/cloudflare-workers/serve-static.ts#L21-L42), [src/middleware/serve-static/index.ts:35-126](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/middleware/serve-static/index.ts#L35-L126)

Cloudflare Pages adapters provide `handle` for routing Pages Functions and `handleMiddleware` for executing individual middleware layers against `EventContext`. The `serveStatic` helper inside Cloudflare Pages queries `env.ASSETS.fetch` directly to serve assets from advanced mode configurations.

```typescript
export const serveStatic = (): MiddlewareHandler => {
  return async (c) => {
    const env = c.env as { ASSETS: FetcherLike }
    const res = await env.ASSETS.fetch(c.req.raw)
    if (res.status === 404) {
      return c.notFound()
    }
    return res
  }
}
```

Sources: [src/adapter/cloudflare-pages/handler.ts:32-46](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/cloudflare-pages/handler.ts#L32-L46), [src/adapter/cloudflare-pages/handler.ts:114-123](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/cloudflare-pages/handler.ts#L114-L123)

---

## Edge and Serverless Adapters

Edge and serverless adapters unify other hosting providers like Vercel, Netlify, and generic Service Workers. The Vercel adapter exports a minimal request handler that forwards incoming requests directly to `app.fetch(req)`.

Sources: [src/adapter/vercel/handler.ts:4-8](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/vercel/handler.ts#L4-L8), [src/adapter/netlify/handler.ts:4-10](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/netlify/handler.ts#L4-L10)

Similarly, the Netlify adapter wraps requests into Hono execution calls with binding contexts. Service worker handlers listen for fetch events (`addEventListener('fetch')`), invoking `app.fetch` with execution contexts and falling back to global fetch operations on 404 statuses if configured.

```typescript
export const handle = <E extends Env, S extends Schema, BasePath extends string>(
  app: Hono<E, S, BasePath>,
  opts: HandleOptions = {
    fetch: globalThis.fetch.bind(globalThis),
  }
): Handler => {
  return (evt) => {
    evt.respondWith(
      (async () => {
        const res = await app.fetch(evt.request, {}, evt)
        if (opts.fetch && res.status === 404) {
          return await opts.fetch(evt.request)
        }
        return res
      })()
    )
  }
}
```

Sources: [src/adapter/service-worker/handler.ts:18-36](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/service-worker/handler.ts#L18-L36), [src/adapter/service-worker/index.ts:28-34](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/adapter/service-worker/index.ts#L28-L34)

---

## Runtime Detection and Environment Helper

The adapter helper module provides runtime detection and environment binding resolution via `getRuntimeKey()` and `env(c)`. `getRuntimeKey()` inspects `navigator.userAgent`, global objects (`EdgeRuntime`, `fastly`), and `process.release.name` to categorize the host engine into a recognized `Runtime` type.

| Runtime Key | Detection Condition | Environment Source |
| :--- | :--- | :--- |
| `deno` | `navigator.userAgent` starts with `'Deno'` | `Deno.env.toObject()` |
| `bun` | `navigator.userAgent` starts with `'Bun'` | `globalEnv` (`process.env`) |
| `workerd` | `navigator.userAgent` starts with `'Cloudflare-Workers'` | `c.env` |
| `node` | `global.process.release.name === 'node'` | `globalEnv` (`process.env`) |
| `edge-light` | `typeof global.EdgeRuntime === 'string'` | `globalEnv` (`process.env`) |
| `fastly` | `global.fastly !== undefined` | `{}` |
| `other` | Fallback when undetected | `{}` |

Sources: [src/helper/adapter/index.ts:8-41](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/helper/adapter/index.ts#L8-L41), [src/helper/adapter/index.ts:43-84](https://github.com/blade47/hono/blob/e50df01453e71b071c3e6136b161b160b9fdf916/src/helper/adapter/index.ts#L43-L84)

## Related

- [Static File Serving](https://www.doc0.dev/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/technical/helpers-and-tooling/static-file-serving)
- [Request Lifecycle](https://www.doc0.dev/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/technical/core-engine/request-lifecycle)


## Sitemap

See the full [sitemap](https://www.doc0.dev/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/llms.txt) for all pages in this wiki.
