Skip to content

Hono

A Hono app runs as a Cloudflare Worker: your code is bundled into one module and handles every request to the environment.

Detection

A project is Hono when hono is in its dependencies. A project that depends on both hono and @rasenganjs/futon fails detection; deploy each app as its own project.

Your entry file

The entry must default-export the app. This is what Hono's Cloudflare Workers template already does:

src/index.ts
import { Hono } from 'hono';
 
const app = new Hono();
 
app.get('/', (c) => c.text('Hello from Hiraiship'));
 
export default app;

A Node.js server doesn't run on Workers: an entry calling serve() from @hono/node-server fails the build with a message saying so. Keep that call in a separate file for local development, or use wrangler dev.

How the entry is found

Hiraiship runs your build command, then bundles the first entry that exists, in this order:

  1. index.js inside the output directory (dist/index.js by default), if your build compiles one;
  2. the main of your wrangler.toml, wrangler.json or wrangler.jsonc;
  3. src/index.ts, src/index.js, index.ts, index.js.

The entry and everything it imports, hono included, are bundled into one ES module with esbuild. TypeScript needs no build step of its own.

Defaults

SettingDefault
Install commandFrom your lockfile, see Frameworks
Build commandnpm run build --if-present: your build script, or nothing
Output directorydist, where the entry is looked for first

Environment variables

Environment variables are on c.env. Type them with the app's Bindings:

src/index.ts
import { Hono } from 'hono';
 
type Bindings = {
  DATABASE_URL: string;
  STRIPE_SECRET_KEY: string;
};
 
const app = new Hono<{ Bindings: Bindings }>();
 
app.get('/health', (c) => c.json({ database: Boolean(c.env.DATABASE_URL) }));
 
export default app;

What's available

  • Node.js built-ins (node:crypto, node:buffer…) through Cloudflare's compatibility layer.
  • Outgoing fetch calls, up to your plan's subrequests per request.
  • No file system, and no Cloudflare bindings other than your variables: KV, D1 or R2 bindings declared in a wrangler file aren't created.