Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/hono/context.ts>Context

Ultrafast web framework for Cloudflare Workers, Deno, and Bun. Fast, but not only fast.
Extremely Popular
Go to Latest
interface Context
import { type Context } from "https://deno.land/x/hono@v2.1.0/context.ts";

Type Parameters

optional
RequestParamKeyType extends string = string
optional
E extends Partial<Environment> = Environment

Properties

env: E["Bindings"] | Bindings
event: FetchEvent
executionCtx: ExecutionContext
finalized: boolean
header: (name: string, value: string) => void
status: (status: StatusCode) => void
set: { <Key extends keyof ContextVariableMap>(key: Key, value: ContextVariableMap[Key]): void; <Key extends keyof E["Variables"]>(key: Key, value: E["Variables"][Key]): void; (key: string, value: any): void; }
get: { <Key extends keyof ContextVariableMap>(key: Key): ContextVariableMap[Key]; <Key extends keyof E["Variables"]>(key: Key): E["Variables"][Key]; <T = any>(key: string): T; }
pretty: (prettyJSON: boolean, space?: number) => void
newResponse: (
data: Data | null,
status: StatusCode,
headers: Headers,
) => Response
body: (
data: Data | null,
status?: StatusCode,
headers?: Headers,
) => Response
text: (
text: string,
status?: StatusCode,
headers?: Headers,
) => Response
json: <T>(
object: T,
status?: StatusCode,
headers?: Headers,
) => Response
html: (
html: string,
status?: StatusCode,
headers?: Headers,
) => Response
redirect: (location: string, status?: StatusCode) => Response
notFound: () => Response | Promise<Response>

Methods

getter
res(): Response
setter
res(_res: Response)