Skip to main content

HonoRequest

The HonoRequest class wraps the standard Web API Request object and provides convenient methods for accessing request data. It’s available through c.req in handlers and middleware.

Constructor

You typically don’t create HonoRequest instances directly. They’re created by Hono for each request.

Properties

raw

The underlying Web API Request object.

path

The pathname of the request URL.

url

The full URL of the request.

method

The HTTP method of the request.

Path Parameters

param

Get path parameters from the route.
string
Parameter name. If omitted, returns all parameters as an object.
string | Record<string, string> | undefined
The parameter value(s)

Query Parameters

query

Get a query string parameter.
string
Query parameter name. If omitted, returns all parameters as an object.
string | Record<string, string> | undefined
The query parameter value(s)

queries

Get multiple values for a query parameter (e.g., array values).
string
Query parameter name. If omitted, returns all parameters as arrays.
string[] | Record<string, string[]> | undefined
The query parameter value(s) as arrays

Headers

Get request header value(s).
string
Header name. If omitted, returns all headers as an object.
string | Record<string, string> | undefined
The header value(s)

Request Body

json

Parse the request body as JSON.
Promise<T>
Parsed JSON object

text

Parse the request body as plain text.
Promise<string>
Request body as a string

arrayBuffer

Parse the request body as an ArrayBuffer.
Promise<ArrayBuffer>
Request body as an ArrayBuffer

blob

Parse the request body as a Blob.
Promise<Blob>
Request body as a Blob

formData

Parse the request body as FormData.
Promise<FormData>
Request body as FormData

parseBody

Parse multipart/form-data or application/x-www-form-urlencoded bodies.
ParseBodyOptions
Parsing options
Promise<T>
Parsed body data as an object

Validated Data

valid

Get validated data from validators.
keyof ValidationTargets
required
Validation target: ‘json’, ‘form’, ‘query’, ‘param’, ‘header’, or ‘cookie’
T
The validated data

addValidatedData

Add validated data to the request (used internally by validators).
keyof ValidationTargets
required
Validation target
object
required
Validated data to store

Deprecated Methods

matchedRoutes

Deprecated. Use the matchedRoutes helper from hono/route instead.
Get matched routes for the current request.

routePath

Deprecated. Use the routePath helper from hono/route instead.
Get the path of the matched route.

Utility Functions

cloneRawRequest

Clone a HonoRequest’s underlying raw Request object, handling both consumed and unconsumed bodies.
HonoRequest
required
The HonoRequest to clone
Promise<Request>
A new Request object with the same properties
This is particularly useful when you need to:
  • Process the same request body multiple times
  • Pass requests to external services after validation
  • Forward requests after consuming the body

Type Parameters

The HonoRequest class accepts generic type parameters:
string
default:"'/'"
Path parameter type for type-safe param access
Input['out']
default:"{}"
Input type for validated data