/Knowledge/sources/honojs__hono/llms-full/best-practices-don-t-make-controllers-when-possible--58026c1f7973.md
Best Practices: Don't make "Controllers" when possible - hono-docs
Best Practices: Don't make "Controllers" when possible Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt...
Best Practices: Don't make "Controllers" when possible
Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#don-t-make-controllers-when-possible
Summary
When possible, you should not create "Ruby on Rails-like Controllers". ts // 🙁 // A RoR-like Controller const booksList = (c: Context) => { return c.json('list books') } app.get('/books', booksList) The issue is related to types....
Content
When possible, you should not create "Ruby on Rails-like Controllers".
// 🙁
// A RoR-like Controller
const booksList = (c: Context) => {
return c.json('list books')
}
app.get('/books', booksList)
The issue is related to types. For example, the path parameter cannot be inferred in the Controller without writing complex generics.
// 🙁
// A RoR-like Controller
const bookPermalink = (c: Context) => {
const id = c.req.param('id') // Can't infer the path param
return c.json(`get ${id}`)
}
Therefore, you don't need to create RoR-like controllers and should write handlers directly after path definitions.
// 😃
app.get('/books/:id', (c) => {
const id = c.req.param('id') // Can infer the path param
return c.json(`get ${id}`)
})
Metadata
{
"chunk_index": 0,
"citation": "https://hono.dev/llms-full.txt#don-t-make-controllers-when-possible",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / Best Practices > Don't make \"Controllers\" when possible",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 76,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "Best Practices: Don't make \"Controllers\" when possible",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}