releaseย ยทย 

H3 v2

๐ŸŽ‰ H3 v2 is now stable! It is a full rewrite on top of web standards, stays compatible with most v1 utilities, and is faster and smaller than v1.

Read more in Guide.
Read more in Migration.
import { H3, serve } from "h3";

const app = new H3().get("/", () => "โšก๏ธ Tadaa!");

serve(app, { port: 3000 });

#๐ŸŒ Web Standards First

H3 v2 is built on Request, Response, URL and Headers. 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.

import { defineHandler } from "h3";

const handler = defineHandler(async (event) => {
  const { pathname, searchParams } = event.url;
  const accept = event.req.headers.get("Accept");
  const body = await event.req.json();

  event.res.headers.set("x-powered-by", "h3");
  return { hello: "web" };
});
Read more in Event Handlers.

#๐Ÿš€ 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 you need them.

#๐ŸŒณ URLPattern-like Routing

Routing uses ๐ŸŒณ rou3 v1, which supports URLPattern-like syntax: named params, regex constraints, optional and repeated params, groups and wildcards.

app.get("/users/:id(\\d+)", (event) => event.context.params.id);
app.get("/blog/:id(\\d+){-:title}?", (event) => event.context.params);
app.get("/files/:path+", (event) => event.context.params.path);

rou3 still matches routes segment by segment in a tree, so lookups stay fast. It differs from URLPattern in a few intentional ways, such as ignoring one trailing slash. See the rou3 route patterns docs for the full syntax and differences.

Read more in Routing.

#๐Ÿงฉ Middleware and Plugins

H3 v2 supports (event, next) middleware, built-in helpers (onRequest, onResponse, onError, basicAuth, bodyLimit, ...) and reusable plugins with definePlugin().

app.use(async (event, next) => {
  const body = await next();
  event.res.headers.append("x-middleware", "works");
  return body;
});
Read more in Middleware.

#๐Ÿ”’ Type Safety

Handlers, responses and errors (HTTPError) are typed. Validated handlers and body/query/params validation work with any Standard Schema library.

#๐Ÿ“ Route Rules

The new h3/rules engine adds headers, redirects, CORS, caching and proxying to groups of routes with one config object.

import { routeRules } from "h3/rules";

app.use(
  routeRules({
    "/old/**": { redirect: "/new/**" },
    "/assets/**": { headers: { "cache-control": "s-maxage=31536000" } },
    "/api/**": { cors: true },
  }),
);
Read more in Route Rules.

#๐Ÿงฐ Built-in Utilities

H3 includes utilities for cookies (including chunked cookies), sessions, CORS, proxying, static files, cache headers, server-sent events, WebSockets via ๐Ÿ”Œ crossws, JSON-RPC/MCP helpers and an h3/tracing plugin.

Read more in Utilities.

#โฌ†๏ธ Upgrading

Most v1 utilities keep working, and deprecated v1 names are still exported to make upgrading easier. H3 v2 requires Node.js >= 20.19 when running on Node.js.

Read more in Migration Guide.

#โค๏ธ Special Thanks

Thank you to all contributors, to everyone who tested the betas and release candidates and reported issues, to the community, to the Nitro community for using v2 throughout its development, and to our sponsors who make it possible to work on open source.

Join our Discord to share your experience and feedback!

H3 ย Universal, Tiny, and Fast Servers.