/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)