/Wiki/sources/honojs__hono/2026/https-hono-dev-llms-full-txt-accessing-eventcont-2f3ea4788e0b-accessing-eventcontext-s0479-c0000.md

Accessing `EventContext` - hono-docs

Accessing EventContext Source evidence: /Sources/raw/honojs hono/honojs hono.md Canonical citation: https://hono.dev/llms full.txt accessing eventcontext Sum...

Accessing EventContext

Source evidence: /Sources/raw/honojshono/honojshono.md Canonical citation: https://hono.dev/llms-full.txt#accessing-eventcontext

Summary

You can access EventContext object via c.env in handleMiddleware. ```ts // functions/_middleware.ts import { handleMiddleware } from 'hono/cloudflare-...

Content

You can access EventContext object via c.env in handleMiddleware.

// functions/_middleware.ts
import { handleMiddleware } from 'hono/cloudflare-pages'

export const onRequest = [
  handleMiddleware(async (c, next) => {
    c.env.eventContext.data.user = 'Joe'
    await next()
  }),
]

Then, you can access the data value in via c.env.eventContext in the handler:

// functions/api/[[route]].ts
import type { EventContext } from 'hono/cloudflare-pages'
import { handle } from 'hono/cloudflare-pages'

// ...

type Env = {
  Bindings: {
    eventContext: EventContext
  }
}

const app = new Hono<Env>().basePath('/api')

app.get('/hello', (c) => {
  return c.json({
    message: `Hello, ${c.env.eventContext.data.user}!`, // 'Joe'
  })
})

export const onRequest = handle(app)
Kinic Wiki
Loading knowledge node
Details

Identity

database
db_23dhmsxlhukv
database_id
db_23dhmsxlhukv
path
/Wiki/sources/honojs__hono/2026/https-hono-dev-llms-full-txt-accessing-eventcont-2f3ea4788e0b-accessing-eventcontext-s0479-c0000.md
kind
directory
role
markdown_note
children
0

Metadata

created_at
virtual
updated_at
virtual
etag
virtual
metadata_json
{}

Lint Hints

No lightweight warnings.

Outgoing Links

No outgoing links indexed.

Incoming Links

Select a file node to inspect backlinks.

Raw Source

No raw source path inferred.