/Wiki/sources/honojs__hono/2026/https-hono-dev-llms-full-txt-generics-f8dc028c3a9c-generics-s0626-c0000.md
Generics - hono-docs
Generics Source evidence: /Sources/raw/honojs hono/honojs hono.md Canonical citation: https://hono.dev/llms full.txt generics Summary You can pass Generics t...
Generics
Source evidence: /Sources/raw/honojshono/honojshono.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()
})