Minimal H(TTP) framework built for high performance and portability.
h3 is a lightweight HTTP server framework built for speed, portability, and modern JavaScript patterns. Created by the UnJS ecosystem team, it powers frameworks like Nuxt and Nitro while remaining usable as a standalone server library. With over 4 million weekly downloads, h3 has gained traction as a performant alternative to Express.
The framework was designed to address performance bottlenecks and architectural limitations in traditional Node.js frameworks. It achieves 2-3x faster routing than Express through optimized path matching algorithms that avoid regex overhead. Rather than the middleware chain pattern with callback functions and next(), h3 uses composable event handlers that work with native Promises and async/await.
h3 includes batteries-included utilities for common HTTP tasks—body parsing, cookie management, CORS headers, query parameters, and error handling—that typically require separate packages in other frameworks. The API design follows modern web standards, with request/response patterns similar to the Fetch API, making it familiar for developers working across different JavaScript runtimes.
The framework runs anywhere JavaScript executes: traditional Node.js servers, serverless functions (AWS Lambda, Cloudflare Workers), and edge computing platforms (Vercel Edge, Deno Deploy). This portability comes from h3's runtime-agnostic design that abstracts platform differences while maintaining consistent APIs across environments.
import { createServer } from 'node:http';
import { createApp, createRouter, eventHandler, readBody, getQuery } from 'h3';
const app = createApp();
const router = createRouter();
// GET route with query parameters
router.get('/users', eventHandler(async (event) => {
const { limit = 10 } = getQuery(event);
return { users: [], limit: Number(limit) };
}));
// POST route with body parsing
router.post('/users', eventHandler(async (event) => {
const body = await readBody(event);
return {
id: crypto.randomUUID(),
name: body.name,
email: body.email,
createdAt: new Date().toISOString()
};
}));
// Route with path parameters
router.get('/users/:id', eventHandler((event) => {
const id = event.context.params?.id;
return { id, name: 'John Doe', email: 'john@example.com' };
}));
// Error handling
router.get('/error', eventHandler(() => {
throw createError({ statusCode: 400, message: 'Bad request' });
}));
app.use(router);
createServer(app).listen(3000, () => {
console.log('Server running on http://localhost:3000');
});High-throughput REST APIs: Applications serving thousands of requests per second benefit from h3's routing performance and memory efficiency. The reduced overhead compared to Express translates to lower infrastructure costs and faster response times under load.
Edge computing and serverless functions: h3's small bundle size and cold-start optimization make it ideal for environments where initialization time matters. It works natively in Cloudflare Workers, Vercel Edge Functions, and similar platforms without Node.js-specific dependencies.
Full-stack frameworks and meta-frameworks: Nuxt 3 and Nitro use h3 as their underlying HTTP layer. If you're building a framework or developer tool that needs embedded HTTP capabilities, h3 provides a solid, well-maintained foundation.
Microservices with TypeScript: The framework has first-class TypeScript support with full type inference for request bodies, query parameters, and route handlers. This makes it suitable for type-safe microservice architectures where compile-time checks prevent runtime errors.
Migration from Express for greenfield projects: New API projects that don't require Express-specific middleware can leverage h3's modern architecture without the technical debt of callback-based patterns. The performance gains and cleaner async code justify the learning curve for teams starting fresh.
npm install h3pnpm add h3bun add h3