/Wiki/sources/honojs__hono/2026/https-hono-dev-llms-full-txt-factory-createapp-7556925aa562-factory-createapp-s0662-c0000.md
`factory.createApp()` (1) - hono-docs
factory.createApp() (1) Source evidence: /Sources/raw/honojs hono/honojs hono.md Canonical citation: https://hono.dev/llms full.txt factory createapp Summary...
factory.createApp() (1)
Source evidence: /Sources/raw/honojshono/honojshono.md Canonical citation: https://hono.dev/llms-full.txt#factory-createapp
Summary
createApp() helps to create an instance of Hono with the proper types. If you use this method with createFactory(), you can avoid redundancy in the definition of the Env type. If your application is like this, you have to set the `...
Content
createApp() helps to create an instance of Hono with the proper types. If you use this method with createFactory(), you can avoid redundancy in the definition of the Env type.
If your application is like this, you have to set the Env in two places:
import { createMiddleware } from 'hono/factory'
type Env = {
Variables: {
myVar: string
}
}
// 1. Set the `Env` to `new Hono()`
const app = new Hono<Env>()
// 2. Set the `Env` to `createMiddleware()`
const mw = createMiddleware<Env>(async (c, next) => {
await next()
})
app.use(mw)By using createFactory() and createApp(), you can set the Env only in one place.