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

x/hono/context.ts>HonoContext

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

Constructors

new
HonoContext(
req: Request,
env?: E["Bindings"] | undefined,
executionCtx?: FetchEvent | ExecutionContext | undefined,
notFoundHandler?: NotFoundHandler,
)

Type Parameters

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

Properties

private
_executionCtx: FetchEvent | ExecutionContext | undefined
private
_headers: Record<string, string> | undefined
private
_map: Record<string, any> | undefined
private
_pretty: boolean
private
_prettySpace: number
private
_res: Response | undefined
private
notFoundHandler: NotFoundHandler
_status: StatusCode
env: Environment["Bindings"]
readonly
event: FetchEvent
readonly
executionCtx: ExecutionContext
finalized: boolean

Methods

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