/Wiki/sources/honojs__hono/2026/https-hono-dev-llms-full-txt-path-parameters-a2a4cb5356ac-path-parameters-s0053-c0000.md
Path parameters - hono-docs
Path parameters Source evidence: /Sources/raw/honojs hono/honojs hono.md Canonical citation: https://hono.dev/llms full.txt path parameters Summary You can a...
Path parameters
Source evidence: /Sources/raw/honojshono/honojshono.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`
},
})