/Knowledge/sources/honojs__hono/llms-full/rpc-path-parameters--28fd2c428e2b.md
RPC: Path parameters - hono-docs
RPC: Path parameters Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt path parameters Summary You can a...
RPC: Path parameters
Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#path-parameters
Summary
You can also handle routes that include path parameters or query values. ```ts const route = app.get( '/posts/:id', zValidator( 'query', z.object({ page: z.coerce.number().optional(), // coerce to convert to number }) ), (c) => { // ......
Content
You can also handle routes that include path parameters or query values.
const route = app.get(
'/posts/:id',
zValidator(
'query',
z.object({
page: z.coerce.number().optional(), // coerce to convert to number
})
),
(c) => {
// ...
return c.json({
title: 'Night',
body: 'Time to sleep',
})
}
)
Both path parameters and query values must be passed as string, even if the underlying value is of a different type.
Specify the string you want to include in the path with param, and any query values with query.
const res = await client.posts[':id'].$get({
param: {
id: '123',
},
query: {
page: '1', // `string`, converted by the validator to `number`
},
})
Metadata
{
"chunk_index": 0,
"citation": "https://hono.dev/llms-full.txt#path-parameters",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / RPC > Path parameters",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 53,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "RPC: Path parameters",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}