DEV Community

Alex Spinov
Alex Spinov

Posted on

Hono Has a Free API You Should Know About

Hono is an ultrafast web framework for the Edge. It runs on Cloudflare Workers, Deno, Bun, Vercel, AWS Lambda, and Node.js — write once, deploy anywhere.

Why Hono is the Edge Framework

A developer needed one API that runs on Cloudflare Workers in production and Node.js in development. Express doesn't work on Workers. Hono runs everywhere — same code, any runtime.

Key Features:

  • Multi-Runtime — Cloudflare, Deno, Bun, Node.js, AWS Lambda
  • Ultrafast — Zero-overhead router, fastest in benchmarks
  • Tiny — 14KB, no dependencies
  • Middleware — Auth, CORS, compression, logging built-in
  • RPC Mode — Type-safe client like tRPC

Quick Start

npm create hono@latest
Enter fullscreen mode Exit fullscreen mode
import { Hono } from "hono"

const app = new Hono()

app.get("/", (c) => c.text("Hello Hono!"))

app.get("/api/users/:id", (c) => {
  const id = c.req.param("id")
  return c.json({ id, name: "Alice" })
})

app.post("/api/users", async (c) => {
  const body = await c.req.json()
  return c.json({ created: true, ...body }, 201)
})

export default app
Enter fullscreen mode Exit fullscreen mode

Middleware

import { cors } from "hono/cors"
import { jwt } from "hono/jwt"
import { logger } from "hono/logger"

app.use("*", logger())
app.use("/api/*", cors())
app.use("/api/*", jwt({ secret: "my-secret" }))
Enter fullscreen mode Exit fullscreen mode

RPC Mode (Type-Safe Client)

// Server
const route = app.get("/api/users", (c) => c.json([{ name: "Alice" }]))
export type AppType = typeof route

// Client
import { hc } from "hono/client"
const client = hc<AppType>("http://localhost:3000")
const res = await client.api.users.$get() // Fully typed!
Enter fullscreen mode Exit fullscreen mode

Why Choose Hono

  1. Any runtime — same code everywhere
  2. Ultrafast — fastest web framework
  3. Type-safe — RPC client with full inference

Check out Hono docs to get started.


Building edge APIs? Check out my Apify actors or email spinov001@gmail.com for custom solutions.

Top comments (0)