github h3js/h3 v2.0.1

5 hours ago

H3 v2 is now stable! 🎉

Note

A full release article is coming soon on the H3 blog.

H3 v2 is a full rewrite on top of web standards (Request, Response, URL, Headers). It stays compatible with most v1 utilities and is faster and smaller than v1.

👉 Get started: https://h3.dev/guide
👉 Upgrading from v1: https://h3.dev/migration

Highlights

  • 🌐 Web standards first: Handlers receive event.req (a standard Request) and event.url, and set response headers through event.res. Return any value (string, object, Response, stream, Blob, ...) and H3 converts it to a Response.
  • 🚀 Runs everywhere: The same app runs on Node.js, Bun, Deno, Cloudflare Workers, Service Workers and browsers. srvx provides a universal server layer, and event.req.runtime gives access to runtime-specific details when needed.
  • ⚡ Fast and small: Routing uses rou3 v1, and the core is a fraction of v1's bundle size. Every handler can be called directly with handler.fetch().
  • 🧩 Middleware and plugins: Onion-style (event, next) middleware, built-in helpers (onRequest, onResponse, onError, basicAuth, bodyLimit, ...) and reusable definePlugin() extensions.
  • 🔒 Type safety: Typed handlers, responses and errors (HTTPError), plus validated handlers and body/query/params validation with any Standard Schema library.
  • 📏 Route rules (h3/rules): Add headers, redirects, CORS, caching and proxying to groups of routes with one config object. See the Route Rules guide.
  • 🧰 Built-in utilities: Cookies (including chunked), sessions, CORS, proxy, static files, cache headers, SSE, WebSockets via crossws, JSON-RPC/MCP helpers and an h3/tracing plugin. See https://h3.dev/utils.

Requirements

  • Node.js >= 20.19 (if you run on Node.js)

Upgrading

Most v1 utilities keep working, and deprecated v1 names are still exported to make upgrading easier. Read the migration guide for the breaking changes and their new equivalents.

Thanks

Thank you to everyone who tested the betas and release candidates, reported issues, and sent PRs, and to the Nitro community for using v2 throughout its development. ❤️

For background on the v2 design, see the v2 beta announcement.

Don't miss a new h3 release

NewReleases is sending notifications on new releases.