Skip to main content
Node.js is the most popular JavaScript runtime. Hono works seamlessly with Node.js using built-in adapters or standard Web APIs.

Quick Start

Create a new Hono project for Node.js:
Select “nodejs” as your template when prompted.

Installation

Add Hono to your existing Node.js project:
For Node.js v18+, you can use the built-in fetch adapter. For earlier versions, install an adapter:

Basic Usage

Using Node.js Adapter

Create your application with the Node.js adapter:
index.ts

Using Native Node.js APIs

For Node.js v18.0.0+, you can use native fetch support:
index.ts
Using @hono/node-server is recommended as it handles request/response conversion automatically.

Running Your App

With TypeScript

Using tsx for development:
Or add to package.json:
package.json

With JavaScript

Adapter Features

Static Files

Serve static files using the node-server adapter:

Connection Info

Get connection information:

Environment Variables

Load environment variables using dotenv:
.env
index.ts

Database Integration

PostgreSQL with Drizzle ORM

MongoDB

Middleware

CORS

Logger

Testing

Use any Node.js testing framework. Example with Vitest:
index.test.ts
Run tests:

Deployment

VPS/Cloud Server

1

Build your application

2

Install dependencies on server

3

Run with PM2

Install PM2:
Start your app:

Docker

Create a Dockerfile:
Dockerfile
Build and run:

Heroku

Create a Procfile:
Deploy:

Best Practices

Use PM2 or systemd to keep your app running and handle restarts.
Use Node.js cluster module or PM2 cluster mode for better performance.
Implement proper error handling and logging.
TypeScript provides better type safety and developer experience.

Performance Tips

  • Use Node.js v20+ for best performance
  • Enable HTTP/2 with the http2 module
  • Implement caching strategies (Redis, in-memory)
  • Use a reverse proxy (nginx, Caddy) in production
  • Enable gzip/brotli compression

Resources

Node.js Documentation

Official Node.js documentation

@hono/node-server

Node.js adapter for Hono