Hono Web Framework
Hono is a small, simple, and ultrafast web framework built entirely on Web Standards. It supports a wide range of JavaScript runtimes including Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, AWS Lambda, Lambda@Edge, and Node.js. The current stable version is 4.12.14, with frequent patch releases addressing bug fixes and security vulnerabilities.
Common errors
-
TypeError: 'parseBody' is not a function
cause The `parseBody` method was incorrectly cached as a property within the request body, leading to a TypeError when accessed subsequently.fixUpgrade Hono to v4.12.9 or later to resolve the caching issue for `parseBody`. -
Malformed HTML output or unexpected attributes appearing in server-side rendered JSX using `hono/jsx`.
cause Improper validation of JSX attribute names during server-side rendering allowed malformed keys to corrupt the generated HTML output.fixUpgrade Hono to v4.12.14 or later to fix JSX attribute name handling and prevent HTML corruption. -
Unauthorized access to static files occurs when using `serveStatic` middleware with URLs containing repeated slashes (e.g., `//`).
cause A path normalization inconsistency in the `serveStatic` middleware allowed repeated slashes to bypass route-based middleware protections.fixUpgrade Hono to v4.12.12 or later to patch the middleware bypass vulnerability in `serveStatic`.
Warnings
- gotcha Hono/jsx SSR can generate malformed HTML or inject unintended attributes due to improper handling of JSX attribute names.
- gotcha The `serveStatic` middleware is vulnerable to path bypass via repeated slashes, potentially allowing unauthorized access to static files.
- gotcha The `toSSG()` function used for static site generation has a path traversal vulnerability, which could lead to files being written outside the intended output directory.
- gotcha Using `parseBody({ dot: true })` can lead to prototype pollution due to improper handling of `__proto__` path segments.
Install
-
npm install hono -
yarn add hono -
pnpm add hono
Imports
- Hono
import { Hono } from 'hono'
Quickstart
import { Hono } from 'hono'
const app = new Hono()
app.get('/', (c) => c.text('Hono!'))
export default app