Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@vercel/h3

Package Overview
Dependencies
Maintainers
321
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vercel/h3

canary
latest
Source
npmnpm
Version
0.1.2
Version published
Weekly downloads
466K
186.29%
Maintainers
321
Weekly downloads
 
Created

What is @vercel/h3?

@vercel/h3 is a minimalistic HTTP framework for building web applications and APIs. It is designed to be lightweight and fast, making it suitable for serverless environments and edge computing.

What are @vercel/h3's main functionalities?

Creating a basic HTTP server

This code demonstrates how to create a basic HTTP server using @vercel/h3. The server listens on port 3000 and responds with 'Hello, world!' to any incoming request.

const { createServer } = require('@vercel/h3');

const app = createServer((req, res) => {
  res.end('Hello, world!');
});

app.listen(3000, () => {
  console.log('Server is running on http://localhost:3000');
});

Handling JSON requests and responses

This example shows how to handle JSON requests and send JSON responses using @vercel/h3. The server reads a JSON body from the request, processes it, and sends a JSON response.

const { createServer, json } = require('@vercel/h3');

const app = createServer(async (req, res) => {
  const body = await json(req);
  res.setHeader('Content-Type', 'application/json');
  res.end(JSON.stringify({ message: 'Hello, ' + body.name }));
});

app.listen(3000, () => {
  console.log('Server is running on http://localhost:3000');
});

Middleware support

This code demonstrates how to use middleware in @vercel/h3. A simple logger middleware is created and applied to the server, logging each request's method and URL.

const { createServer, use } = require('@vercel/h3');

const logger = (req, res, next) => {
  console.log(`${req.method} ${req.url}`);
  next();
};

const app = createServer();

use(app, logger);

app.use((req, res) => {
  res.end('Hello, world!');
});

app.listen(3000, () => {
  console.log('Server is running on http://localhost:3000');
});

Other packages similar to @vercel/h3

FAQs

Package last updated on 22 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts