Install Hono
Add Hono to your project using your preferred package manager:Basic Setup
Once installed, create your first Hono application:index.ts
Package Exports
Hono provides multiple entry points for different use cases. Here are the most common imports:Core Framework
Middleware
Helpers
Runtime Adapters
Presets
Hono offers optimized presets for different use cases. These presets use different routers under the hood for specific performance characteristics.Standard (Default)
The default import usesSmartRouter which combines RegExpRouter and TrieRouter for optimal performance:
- Excellent routing performance
- Support for all routing patterns
- Automatic router selection based on route complexity
Tiny Preset
For applications where bundle size is critical (under 12kB), use thetiny preset with PatternRouter:
- Smallest bundle size (under 12kB)
- Zero dependencies
- Uses only Web Standard APIs
- Ideal for Cloudflare Workers and edge environments
Quick Preset
For simpler applications with linear routing needs, use thequick preset with LinearRouter:
- Uses
LinearRoutercombined withTrieRouter - Optimized for applications with fewer routes
- Good balance between size and performance
The choice of preset mainly affects routing performance and bundle size. The API remains the same across all presets.
Runtime-Specific Setup
Depending on your deployment target, you may need additional setup:- Cloudflare Workers
- Node.js
- Bun
- Deno
- AWS Lambda
- Vercel
No additional setup required. Just export your app:Add to your
wrangler.toml:TypeScript Configuration
For the best development experience with TypeScript, ensure yourtsconfig.json includes:
tsconfig.json
Adjust the
types field based on your runtime. For Node.js, use ["node"]. For Deno, this field is not needed.Package.json Setup
Here’s a minimalpackage.json for a Hono project:
package.json
Verifying Installation
Test that Hono is correctly installed by running a simple script:test.ts
Next Steps
Now that Hono is installed, you’re ready to build:Quickstart Guide
Build your first Hono application
Routing
Learn about routes and path patterns
Middleware
Explore built-in and custom middleware
API Reference
Dive into the complete API documentation