/Knowledge/sources/honojs__hono/llms-full/app-hono-generics--1313a8283c80.md
App - Hono: Generics - hono-docs
App Hono: Generics Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt generics Summary You can pass Gener...
App - Hono: Generics
Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#generics
Summary
You can pass Generics to specify the types of Cloudflare Workers Bindings and variables used in c.set/c.get. ```ts twoslash import { Hono } from 'hono' type User = any declare const user: User // ---cut--- type Bindings = { TOKEN: st...
Content
You can pass Generics to specify the types of Cloudflare Workers Bindings and variables used in c.set/c.get.
import { Hono } from 'hono'
type User = any
declare const user: User
// ---cut---
type Bindings = {
TOKEN: string
}
type Variables = {
user: User
}
const app = new Hono<{
Bindings: Bindings
Variables: Variables
}>()
app.use('/auth/*', async (c, next) => {
const token = c.env.TOKEN // token is `string`
// ...
c.set('user', user) // user should be `User`
await next()
})
Metadata
{
"chunk_index": 0,
"citation": "https://hono.dev/llms-full.txt#generics",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / App - Hono > Generics",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 626,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "App - Hono: Generics",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}