/Knowledge/sources/honojs__hono/llms-full/cloudflare-pages-cloudflare-pages-middleware-accessing-eventcontext--6330b336f2d0.md
Cloudflare Pages: Cloudflare Pages Middleware > Accessing EventContex...
Cloudflare Pages: Cloudflare Pages Middleware Accessing EventContext Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev...
Cloudflare Pages: Cloudflare Pages Middleware > Accessing EventContext
Source evidence: /Sources/honojs__hono/provenance.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)
Metadata
{
"chunk_index": 0,
"citation": "https://hono.dev/llms-full.txt#accessing-eventcontext",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / Cloudflare Pages > Cloudflare Pages Middleware > Accessing `EventContext`",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 479,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "Cloudflare Pages: Cloudflare Pages Middleware > Accessing EventContext",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}