Every time I start a new HTTP API on Lambda, the same discussion comes up in my team: do we give each route its own function, or do we put the whole API into one? For a long time I split everything by reflex. Today I usually start the other way round, with one function that does its own routing, and Hono has become my favourite tool for that.

If you want the complete walkthrough with all files, tests and the deployment, you can find it in my full article on running Hono on AWS Lambda with the Serverless Framework. Here I want to share the ideas behind it and the one pitfall that currently catches many people.

Why a single function can be the better default

Hono is a small TypeScript web framework that is built on the web standards Request and Response. That makes it portable: the same app runs on Cloudflare Workers, Deno, Bun, Node.js and Lambda. On Lambda, an adapter translates the API Gateway event into a normal Request and turns the response back into what API Gateway expects. Compared to Express, it has hardly any dependencies and starts fast, which matters when cold starts are part of your life.

A single function serving all routes is often called a Lambdalith. What convinces me is the daily work with it:

  • One deployment artifact, one configuration, one place for middleware like logging or authentication.
  • Warm execution environments are shared across all routes, so rarely used endpoints see fewer cold starts.
  • You can test the whole API locally with a single call.

The trade-offs are real, though. All routes share one IAM role, one memory setting and one timeout. If one endpoint needs write access to a bucket, every endpoint gets it. And Lambda metrics only show you one function, so per-route numbers have to come from API Gateway or your logs.

My rule of thumb: start with the Lambdalith and pull a route out only when its needs clearly differ. A memory-hungry PDF export, an endpoint with special permissions or anything that runs for more than a few seconds are typical candidates.

The import that will break with Hono v5

Hono recently moved its Lambda adapter into a separate package, @hono/aws-lambda. Many tutorials still import handle from hono/aws-lambda. That path still works in Hono 4, but it is marked as deprecated and is meant to disappear in version 5. If you start today, use the new package right away; for existing projects it is a one-line change.

// src/handler.ts import { handle } from '@hono/aws-lambda'; import { app } from './app.js'; export const handler = handle(app); 

The nice part: handle figures out by itself whether the event comes from an HTTP API, a REST API, an Application Load Balancer or a function URL.

Keeping the app testable and the deployment boring

The structure I recommend separates the Hono app from the Lambda handler. That pays off immediately in tests: with app.request() you send a request straight into the app, without a server and without an AWS account. I still add one test that calls the real handler with an API Gateway event in format 2.0, so I know the adapter wiring works too.

For input validation I use Zod together with the Hono validator middleware. You validate query parameters and the JSON body separately, read the checked data with c.req.valid(), and TypeScript knows the exact type. A small hook lets you control what a 400 response looks like, so errors stay consistent across the API.

The deployment is refreshingly unspectacular. Serverless Framework v4 ships with esbuild and builds TypeScript handlers without an extra plugin, so the classic serverless-esbuild setup is no longer needed.

A few things I would watch out for:

  • Query parameters always arrive as strings, so numbers need explicit coercion.
  • Every library ends up in the bundle and lengthens the cold start.
  • An HTTP API without an authorizer is public.

What the full article covers

  • The complete example API for a fictional city library, step by step from project setup to routes
  • Validation with Zod and the error hook in detail
  • Tests with app.request() plus a real Lambda event
  • The full serverless.yml, deployment and common mistakes like binary responses
  • FAQ on Node.js 24, REST APIs, function URLs and Hono vs. Express

Read the full guide here: Hono on AWS Lambda: REST API with Serverless Framework

📖 This is the condensed version. The full article on sascha-ms.de goes deeper – with all code samples, diagrams and a short knowledge check.

👉 Next step: Curious what your own Lambda functions cost? Try my Lambda cost calculator – it runs right in your browser.

📬 Stay updated: New articles on serverless, AI and leading tech teams via RSS, browser push or the weekly newsletter (in German).

Originally published on sascha-ms.de. More articles on serverless, AI in everyday development and leading tech teams: sascha-ms.de/en