Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hono

Package Overview
Dependencies
Maintainers
1
Versions
338
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hono

Ultrafast web framework for the Edges

  • 3.12.12
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is hono?

Hono is a small, simple, and fast web framework for building web applications and APIs in Node.js. It is designed to be lightweight and efficient, making it suitable for high-performance applications.

What are hono's main functionalities?

Basic Routing

Hono allows you to define routes for your web application. In this example, a basic GET route is defined that responds with 'Hello, Hono!' when accessed.

const { Hono } = require('hono');
const app = new Hono();

app.get('/', (c) => c.text('Hello, Hono!'));

app.listen(3000);

Middleware Support

Hono supports middleware, allowing you to execute code before your route handlers. This example demonstrates a simple logger middleware that logs the request method and URL.

const { Hono } = require('hono');
const app = new Hono();

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

app.use(logger);

app.get('/', (c) => c.text('Hello, Hono!'));

app.listen(3000);

Error Handling

Hono provides a way to handle errors globally. In this example, an error is thrown in the route handler, and the global error handler responds with a 500 status code and a message.

const { Hono } = require('hono');
const app = new Hono();

app.get('/', (c) => {
  throw new Error('Something went wrong!');
});

app.onError((err, c) => {
  c.status(500);
  return c.text('Internal Server Error');
});

app.listen(3000);

Other packages similar to hono

Keywords

FAQs

Package last updated on 07 Feb 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc