Convert Figma logo to code with AI

honojs logohono

Web framework built on Web Standards

19,332
546
19,332
224

Top Related Projects

31,844

Fast and low overhead web framework, for Node.js

64,773

Fast, unopinionated, minimalist web framework for node.

35,113

Expressive middleware for node.js using ES2017 async functions

66,731

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀

34,688

🧙‍♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy.

Quick Overview

Hono is a lightweight, ultrafast web framework for the edge, designed to work with various JavaScript runtimes like Cloudflare Workers, Deno, and Bun. It offers a simple and intuitive API for building web applications and APIs with excellent performance and minimal overhead.

Pros

  • Extremely fast and lightweight, optimized for edge computing environments
  • Supports multiple JavaScript runtimes, providing flexibility in deployment options
  • Simple and intuitive API, making it easy to learn and use
  • Built-in TypeScript support for improved developer experience

Cons

  • Relatively new project, which may lead to fewer community resources and third-party integrations
  • Limited ecosystem compared to more established frameworks like Express.js
  • May lack some advanced features found in larger, more mature frameworks
  • Documentation, while improving, may not be as comprehensive as that of more established projects

Code Examples

  1. Basic route handling:
import { Hono } from 'hono'

const app = new Hono()

app.get('/', (c) => c.text('Hello Hono!'))
app.get('/user/:id', (c) => {
  const id = c.req.param('id')
  return c.json({ id })
})

export default app
  1. Middleware usage:
import { Hono } from 'hono'
import { logger } from 'hono/logger'

const app = new Hono()

app.use('*', logger())
app.get('/protected', async (c, next) => {
  // Custom authentication middleware
  const token = c.req.header('Authorization')
  if (token !== 'secret-token') {
    return c.text('Unauthorized', 401)
  }
  await next()
})

app.get('/protected', (c) => c.text('Protected route'))

export default app
  1. Using built-in helpers:
import { Hono } from 'hono'
import { cors } from 'hono/cors'

const app = new Hono()

app.use('*', cors())

app.get('/api/data', (c) => {
  return c.json({ message: 'This response has CORS headers' })
})

export default app

Getting Started

To start using Hono, follow these steps:

  1. Install Hono:
npm install hono
  1. Create a new file (e.g., index.js) and add the following code:
import { Hono } from 'hono'

const app = new Hono()

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

export default app
  1. Run the application using your preferred JavaScript runtime (e.g., Deno, Bun, or deploy to Cloudflare Workers).

For more detailed instructions and advanced usage, refer to the official Hono documentation.

Competitor Comparisons

31,844

Fast and low overhead web framework, for Node.js

Pros of Fastify

  • Highly performant with excellent benchmarks
  • Extensive plugin ecosystem and middleware support
  • Strong TypeScript support and type safety

Cons of Fastify

  • Steeper learning curve for beginners
  • Larger bundle size compared to Hono
  • More complex setup for simple applications

Code Comparison

Hono:

import { Hono } from 'hono'

const app = new Hono()
app.get('/', (c) => c.text('Hello Hono!'))
export default app

Fastify:

import fastify from 'fastify'

const app = fastify()
app.get('/', async (request, reply) => {
  return 'Hello Fastify!'
})
app.listen({ port: 3000 })

Both Hono and Fastify are popular web frameworks for Node.js, but they have different focuses. Hono is designed to be lightweight and fast, particularly suitable for edge computing environments. It offers a simple API and small bundle size, making it ideal for serverless functions and edge workers.

Fastify, on the other hand, is known for its high performance and extensive feature set. It provides a rich ecosystem of plugins and middleware, making it well-suited for building complex, scalable applications. Fastify also offers excellent TypeScript support and type safety out of the box.

While Fastify may have a steeper learning curve and require more setup for simple applications, it shines in larger, more complex projects where its performance optimizations and extensive plugin system can be fully utilized.

64,773

Fast, unopinionated, minimalist web framework for node.

Pros of Express

  • Mature ecosystem with extensive middleware and plugins
  • Well-established community support and documentation
  • Flexible and unopinionated, allowing for diverse architectural choices

Cons of Express

  • Larger bundle size and slower performance compared to Hono
  • Lacks built-in TypeScript support, requiring additional setup
  • Not optimized for edge computing environments

Code Comparison

Express:

const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.send('Hello World!');
});

Hono:

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

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

Key Differences

  • Hono is designed for edge computing and offers better performance in serverless environments
  • Express has a larger ecosystem and more extensive third-party integrations
  • Hono provides built-in TypeScript support, while Express requires additional configuration
  • Express uses a more traditional middleware approach, while Hono leverages modern JavaScript features

Use Cases

  • Choose Express for traditional Node.js applications with complex middleware requirements
  • Opt for Hono in edge computing scenarios or when prioritizing performance and small bundle size
  • Consider Hono for TypeScript projects seeking a lightweight, fast framework
35,113

Expressive middleware for node.js using ES2017 async functions

Pros of Koa

  • Mature and well-established framework with a large ecosystem
  • Lightweight and minimalist design, allowing for greater flexibility
  • Strong middleware support and composability

Cons of Koa

  • Requires more setup and configuration for basic functionality
  • Less opinionated, which can lead to inconsistencies across projects
  • Async/await support added later, not built from the ground up for it

Code Comparison

Koa:

const Koa = require('koa');
const app = new Koa();

app.use(async ctx => {
  ctx.body = 'Hello World';
});

app.listen(3000);

Hono:

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

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

export default app;

Key Differences

  • Hono is designed for edge computing and supports various runtimes
  • Koa is more focused on traditional Node.js environments
  • Hono has built-in TypeScript support, while Koa requires additional setup
  • Hono offers a more streamlined API with less boilerplate
  • Koa provides more flexibility but requires more manual configuration

Both frameworks have their strengths, with Koa offering a mature ecosystem and flexibility, while Hono provides a more modern, lightweight approach tailored for edge computing and TypeScript projects.

66,731

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀

Pros of Nest

  • Comprehensive, full-featured framework with built-in support for dependency injection, modules, and decorators
  • Strong TypeScript integration and extensive documentation
  • Large ecosystem with many plugins and extensions

Cons of Nest

  • Steeper learning curve due to its complexity and architectural concepts
  • Heavier and potentially slower for simple applications
  • More opinionated, which may limit flexibility in some cases

Code Comparison

Nest:

@Controller('cats')
export class CatsController {
  @Get()
  findAll(): string {
    return 'This action returns all cats';
  }
}

Hono:

const app = new Hono()
app.get('/cats', (c) => {
  return c.text('This action returns all cats')
})

Summary

Nest is a robust, feature-rich framework ideal for large-scale applications, while Hono is a lightweight, fast framework better suited for simpler projects or serverless environments. Nest offers more built-in features and structure but comes with added complexity, whereas Hono provides a more minimalist approach with greater flexibility and ease of use for smaller applications.

34,688

🧙‍♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy.

Pros of tRPC

  • End-to-end type safety across client and server
  • Automatic API documentation generation
  • Simpler setup for full-stack TypeScript projects

Cons of tRPC

  • Limited to TypeScript ecosystems
  • Steeper learning curve for developers new to RPC concepts
  • Less flexibility for non-TypeScript clients

Code Comparison

tRPC:

import { initTRPC } from '@trpc/server';

const t = initTRPC.create();

const appRouter = t.router({
  hello: t.procedure.query(() => 'Hello, World!'),
});

Hono:

import { Hono } from 'hono';

const app = new Hono();

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

Summary

tRPC excels in TypeScript-centric projects, offering strong type safety and automatic documentation. However, it's less versatile for multi-language environments. Hono provides a more traditional, flexible API approach with broader language support but lacks the deep TypeScript integration of tRPC. The choice between them depends on project requirements and team expertise.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README


Documentation 👉 hono.dev
Now supports JSR and deno.land/x is deprecated! See Migration guide.


GitHub Workflow Status GitHub npm npm JSR Bundle Size Bundle Size GitHub commit activity GitHub last commit codecov Discord badge

Hono - means flame🔥 in Japanese - is a small, simple, and ultrafast web framework built on Web Standards. It works on any JavaScript runtime: Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, AWS Lambda, Lambda@Edge, and Node.js.

Fast, but not only fast.

import { Hono } from 'hono'
const app = new Hono()

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

export default app

Quick Start

npm create hono@latest

Features

  • Ultrafast 🚀 - The router RegExpRouter is really fast. Not using linear loops. Fast.
  • Lightweight 🪶 - The hono/tiny preset is under 13kB. Hono has zero dependencies and uses only the Web Standard API.
  • Multi-runtime 🌍 - Works on Cloudflare Workers, Fastly Compute, Deno, Bun, AWS Lambda, Lambda@Edge, or Node.js. The same code runs on all platforms.
  • Batteries Included 🔋 - Hono has built-in middleware, custom middleware, and third-party middleware. Batteries included.
  • Delightful DX 😃 - Super clean APIs. First-class TypeScript support. Now, we've got "Types".

Documentation

The documentation is available on hono.dev.

Migration

The migration guide is available on docs/MIGRATION.md.

Communication

X and Discord channel are available.

Contributing

Contributions Welcome! You can contribute in the following ways.

  • Create an Issue - Propose a new feature. Report a bug.
  • Pull Request - Fix a bug and typo. Refactor the code.
  • Create third-party middleware - Instruct below.
  • Share - Share your thoughts on the Blog, X, and others.
  • Make your application - Please try to use Hono.

For more details, see docs/CONTRIBUTING.md.

Contributors

Thanks to all contributors!

Authors

Yusuke Wada https://github.com/yusukebe

RegExpRouter, SmartRouter, LinearRouter, and PatternRouter are created by Taku Amano https://github.com/usualoma

License

Distributed under the MIT License. See LICENSE for more information.

NPM DownloadsLast 30 Days