Import
Functions
handle()
Converts a Hono application into a Vercel request handler.Parameters
app- The Hono application instance
Returns
A request handler function that can be exported as the default export.Example
getConnInfo()
Extracts connection information from the Vercel request.Returns
Example
Platform-Specific Notes
Edge Runtime vs Serverless
Vercel supports two runtime environments:- Edge Runtime: Runs on Vercel’s Edge Network, closer to users for lower latency
- Serverless Functions: Traditional serverless functions with full Node.js compatibility
vercel.json:
Request Headers
Vercel provides additional headers:x-real-ip- Client’s real IP addressx-forwarded-for- Proxy chainx-vercel-ip-country- Country code (e.g., “US”)x-vercel-ip-city- City name (e.g., “San Francisco”)x-vercel-ip-country-region- Region code (e.g., “CA”)x-vercel-ip-latitude- Latitudex-vercel-ip-longitude- Longitude
File Structure
For file-based routing in theapi/ directory:
Example with Dynamic Routes
Catch-All Routes
For a single handler that handles all routes:Environment Variables
Access Vercel environment variables directly:Configuration
vercel.json
TypeScript Configuration
Deployment
Using Vercel CLI
Using Git Integration
Connect your repository to Vercel:- Import your Git repository at vercel.com/new
- Configure build settings (if needed)
- Deploy automatically on every push