Hono Local Development Guide

Use Hono to build lightweight Web APIs and edge services, with Node.js defaulting to localhost:3000, and can also be deployed to Cloudflare Workers.


Hono is an ultrafast web framework with a simple API and a small footprint, capable of running on multiple runtimes including Cloudflare Workers, Deno, Bun, and Node.js. It is suitable for REST APIs, BFF layers, and edge functions.

Quick Start (Node.js)

npm create hono@latest my-app
cd my-app
npm install
npm run dev

You can choose either the nodejs or cloudflare-workers template.

Default localhost Access

PurposeAddress
Node Development Serverhttp://localhost:3000
Cloudflare Workers Localhttp://localhost:8787 (via wrangler dev)

In the Node template, you can modify the port in the entry file by changing serve({ fetch: app.fetch, port: 3000 }).

Common Commands

CommandDescription
npm run devLocal development (depending on the template, either Node or Wrangler)
wrangler devLocal simulation for Workers (Cloudflare template)
wrangler deployDeploy to Cloudflare Workers

Minimal Example

import { Hono } from 'hono';

const app = new Hono();

app.get('/', (c) => c.json({ message: 'Hello from localhost!' }));
app.get('/api/health', (c) => c.json({ ok: true }));

export default app;

Use Cases

  • Lightweight REST / JSON APIs
  • Integration with frontend SPAs (same-origin or CORS)
  • Edge deployment: low latency, globally distributed

Summary

Hono local Node development typically accesses http://localhost:3000, while the Workers mode uses http://localhost:8787, making it suitable for quickly setting up APIs and edge services.

访客计数:------ Best viewed in Netscape Navigator · 800×600 © LocalHost Run