Hono Backend on Workers
Learn how to create a free, fast, and structured backend using Cloudflare Workers and Hono for relational data.

Build a Minimal CRUD Backend on Cloudflare Workers: Step-by-Step Guide
I was exploring free backend hosting options and ran into the usual problem: one-time credits, unpredictable pricing, and services that wake up cold when you need them. I wanted something free, consistent, and modern, enter Cloudflare Workers.
This guide will walk you through the essentials of setting up a minimal backend. By the end, you'll have a clear path to a lightweight, functional CRUD API.
What is Cloudflare Workers?
Cloudflare Workers is a serverless platform that runs your code at Cloudflare's global data centers (their "edge"). Instead of a single server or virtual machine, your code executes close to the user, which improves speed and reduces latency.
Think of Workers as a globally distributed runtime for JavaScript, giving your APIs ultra-low latency without worrying about infrastructure.
Key points:
- No servers to manage: Upload your code, and Cloudflare runs it.
- Edge execution: Code runs near users worldwide.
- Fast and secure: Uses a lightweight JavaScript environment (V8), not Node.js.
Example: A "Hello World" Worker
export default {
async fetch(request) {
return new Response("Hello World", { status: 200 });
},
};This example illustrates how simple it is to deploy a global endpoint. Users anywhere in the world will hit the nearest edge and get an instant response.
Free Tier Limits
Cloudflare gives a clear free tier, more then enough for mid apps:
- 100,000 requests per day
- 1,000 requests per minute (burst)
- 10 ms CPU time per request
- 3,000 build minutes per month
- Up to 100 Worker scripts
- Key-value storage (KV): 100,000 reads/day, 1,000 writes/day, 1 GB storage
Static assets are free and unlimited.
Understanding the free limits upfront helps prevent surprises and lets you plan for realistic workloads. Most personal or mid-scale projects fit comfortably within these bounds.
Choosing a Framework for CRUD Apps
For a simple CRUD backend, you want something light and fast:
This section compares two popular frameworks suitable for Workers, focusing on footprint, structure, and flexibility.
1. Hono
- Express-like API, small (~22 KB), TypeScript-friendly
- Good for relational data or if you want some middleware
- Example:
import { Hono } from "hono";
const app = new Hono();
app.get("/items", (c) => c.json([{ id: 1, name: "item1" }]));
app.post("/items", async (c) => {
const body = await c.req.json();
return c.json({ id: Date.now(), ...body });
});
export default app;Hono is ideal, mainly for supporting dependent db if you want structure and type safety while keeping the code minimal, It balances simplicity with the ability to grow.
2. itty-router
- Minimal (~1 KB), just routes and CRUD
- Use if you want a tiny footprint
- Example:
import { Router } from "itty-router";
const router = Router();
router.get("/items", () => new Response(JSON.stringify([{ id: 1 }])));
router.post("/items", async (req) => {
const body = await req.json();
return new Response(JSON.stringify({ id: Date.now(), ...body }));
});
export default { fetch: router.handle };itty-router is perfect for extremely minimal setups. but only lookup to a single table It does routing only and leaves you with only single table. (Does not support relational db)
Recommendation
- Hono: best for structured, relational data
- itty-router: smallest possible CRUD backend, single table lookups
I would go with hono, always.
How to Build a Simple Backend
Follow these steps to get a minimal backend running:
This section is a practical roadmap. You’ll see how to initialize a project, pick storage, and deploy quickly.
- Install Wrangler (Cloudflare CLI):
npm install -g wrangler- Create a new Worker project:
wrangler generate my-backend
cd my-backend-
Pick a framework: Hono for structured data, itty-router for tiny not relational CRUD.
-
Define your endpoints:
/items,/customers,/sales, etc. -
Use KV or D1 for storage:
- KV: fast key-value storage, ideal for cached or small JSON objects.
- D1: SQLite-style relational DB at the edge, good for structured data.
-
Deploy to Cloudflare:
wrangler deploy- Test your API: Open the deployed endpoint in a browser or use Postman/cURL.
Breaking the process into small steps makes it manageable, even if you’ve never deployed to edge servers before.
Example: Cooler Management Backend that i built.
Suppose you have entities like:
- Cooler (name, tank size, motor type, color)
- Manufacturer (name, address, phone, GST ID)
- Purchase (cooler ID, manufacturer ID, quantity, date, purchase price)
- Customer (name, phone, GST ID, Aadhaar)
- Sale (customer ID, cooler ID, quantity, date, actual sale price)
This is a relational dataset, so using Hono makes managing endpoints and types much easier.
Because this is relational data with relationships between entities, Hono is the better choice. It allows you to:
- Define structured endpoints for each entity (
/coolers,/manufacturers,/purchases,/customers,/sales) - Integrate with D1 (Cloudflare's edge SQLite) or external databases
- Keep type safety with TypeScript interfaces
- Scale CRUD logic without sacrificing clarity or performance
Minimal Hono CRUD skeleton for Coolers:
import { Hono } from "hono";
const app = new Hono();
type Cooler = {
id: string;
name: string;
tankSize: number;
motorType: string;
color: string;
};
// Create a new cooler
app.post("/coolers", async (c) => {
const body = await c.req.json<Cooler>();
return c.json({ message: "Cooler created", data: body }, 201);
});
// Get all coolers
app.get("/coolers", async (c) => {
return c.json([
{
id: "1",
name: "Symphony",
tankSize: 40,
motorType: "BLDC",
color: "White",
},
]);
});
export default app;This example shows how to start structured CRUD development on Cloudflare Workers. Even with relational data, you can remain minimal, fast, and type-safe.
-- Mohammad
Best Linux Hosting Distros
Comparing Ubuntu, Debian, Arch, and others for performance, footprint, compatibility, and real-world server hosting use cases.
Expo Setup Without Studio
Expo’s own devs recommends using a local development environment and not Expo Go,for production-quality testing and builds. This guide walks you through setting up a complete Expo Android development workflow on Linux using only command-line tools.