Skip to main content
This release is 7 versions behind 4.7.7 — the latest version of @hono/hono. Jump to latest

@hono/hono@4.6.20
Built and signed on GitHub Actions

Web framework built on Web Standards

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
76%
Published
3 months ago (4.6.20)

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

class HonoRequest

Constructors

new
HonoRequest(
request: Request,
path?: string,
matchResult?: Result<[unknown, RouterRoute]>,
)

Type Parameters

P extends string = "/"
I extends Input["out"] = { }

Properties

.matchedRoutes() can return a matched route in the handler

readonly
method: string

.method() can get the method name of the request.

.path can get the pathname of the request.

.raw can get the raw Request object.

routePath() can retrieve the path registered within the handler

readonly
url: string

.url() can get the request url strings.

Methods

addValidatedData(
target: keyof ValidationTargets,
data: { },
): void

Adds validated data to the request.

.arrayBuffer() parse Request body as an ArrayBuffer

Parses the request body as a Blob.

Parses the request body as FormData.

header(name: RequestHeader): string | undefined

.header() can get the request header value.

header(name: string): string | undefined
json<T = any>(): Promise<T>

.json() can parse Request body of type application/json

param<P2 extends ParamKeys<P> = ParamKeys<P>>(key: P2 extends `${infer _}?` ? never : P2): string

.req.param() gets the path parameters.

param<P2 extends RemoveQuestion<ParamKeys<P>> = RemoveQuestion<ParamKeys<P>>>(key: P2): string | undefined
param(key: string): string | undefined
parseBody<
Options extends Partial<ParseBodyOptions>,
T extends BodyData<Options>,
>
(options?: Options): Promise<T>

.parseBody() can parse Request body of type multipart/form-data or application/x-www-form-urlencoded

parseBody<T extends BodyData>(options?: Partial<ParseBodyOptions>): Promise<T>
queries(key: string): string[] | undefined

.queries() can get multiple querystring parameter values, e.g. /search?tags=A&tags=B

queries(): Record<string, string[]>
query(key: string): string | undefined

.query() can get querystring parameters.

query(): Record<string, string>

.text() can parse Request body of type text/plain

valid<T extends keyof I & keyof ValidationTargets>(target: T): InputToDataByTarget<I, T>

Gets validated data from the request.

Add Package

deno add jsr:@hono/hono

Import symbol

import { HonoRequest } from "@hono/hono/request";

---- OR ----

Import directly with a jsr specifier

import { HonoRequest } from "jsr:@hono/hono/request";

Add Package

npx jsr add @hono/hono

Import symbol

import { HonoRequest } from "@hono/hono/request";

Add Package

yarn dlx jsr add @hono/hono

Import symbol

import { HonoRequest } from "@hono/hono/request";

Add Package

pnpm dlx jsr add @hono/hono

Import symbol

import { HonoRequest } from "@hono/hono/request";

Add Package

bunx jsr add @hono/hono

Import symbol

import { HonoRequest } from "@hono/hono/request";