Skip to main content
Vercel is a cloud platform for static sites and serverless functions. Deploy your Hono applications to Vercel’s edge network with ease.

Quick Start

Create a new Hono project for Vercel:
Select “vercel” as your template when prompted.

Installation

Add Hono to your existing Vercel project:

Basic Usage

Create your API in the api directory:
api/index.ts
The handle adapter converts your Hono app into a Vercel serverless function.

Routing

Single API Route

Handle all API routes in one file using basePath:
api/[[...route]].ts

Multiple API Routes

Create separate files for different routes:
api/users/index.ts
api/posts/index.ts

Connection Info

Get connection information:

Environment Variables

Access environment variables in your Hono app:
api/index.ts
Add environment variables in Vercel:
  1. Go to your project settings
  2. Navigate to “Environment Variables”
  3. Add your variables

Configuration

Create a vercel.json configuration file:
vercel.json

Middleware

CORS

api/index.ts

Authentication

api/index.ts

Deployment

1

Install Vercel CLI

2

Login to Vercel

3

Deploy

For production:

Deploy via Git

Connect your Git repository to Vercel:
  1. Push your code to GitHub, GitLab, or Bitbucket
  2. Go to Vercel Dashboard
  3. Click “Import Project”
  4. Select your repository
  5. Configure settings and deploy
Vercel will automatically deploy on every push to your main branch.

Project Structure

Typical Vercel + Hono project structure:

Combining with Frontend Frameworks

With Next.js

Hono works alongside Next.js API routes:
pages/api/[[...route]].ts

With React/Vite

Use Hono for the API and Vite for the frontend:
package.json

Edge Functions

Deploy to Vercel’s Edge Runtime:
api/edge/[[...route]].ts
Edge Functions run on Vercel’s Edge Network for ultra-low latency worldwide.

Database Integration

Vercel Postgres

api/users.ts

Vercel KV (Redis)

api/cache.ts

Best Practices

Always set basePath('/api') to match your API directory structure.
Use Edge Functions for globally distributed, low-latency APIs.
Store secrets in Vercel’s environment variables, not in code.
Use Vercel KV or edge caching for better performance.

Performance Tips

  • Use Edge Functions for global distribution
  • Implement caching with Vercel KV
  • Optimize function memory settings
  • Use ISR (Incremental Static Regeneration) when possible
  • Enable compression for responses

Resources

Vercel Documentation

Official Vercel documentation

Edge Functions

Learn about Edge Functions