Bun Hono API
A Hono todo API reports its Bun version, answers health checks, and supports listing or adding todos. Tokay recognizes the Bun project and runs it as one Web Service.
Last updated
AI agent? Start with llms.txt.
Bring the same TypeScript entry point, package file, and lockfile you use during development. Tokay keeps Bun as the runtime instead of translating the app to Node.js.
- Runtime
- Bun
- Framework
- Hono
- Service types
- Web Service
- Resources
- None
- Required secrets
- None
What it does
The root response shows the Bun version currently serving your API.
Fetch /todos for three sample tasks. Post a nonempty title and Hono returns the new item with a 201 status. Empty input receives a 400 response.
The /health route gives you a direct liveness check.
Deploy it
Bring this folder to Tokay any way you like. Hand it to your AI assistant, drag the unzipped folder in under Add code, or push it with Git. Tokay figures out the rest.
Haven't connected your assistant yet? Set it up once, then ask it to deploy this example. Agents can use Tokay MCP at https://mcp.tokay.io/mcp or the Tokay API, and our agent instructions cover both.
New to Tokay? The getting started guide walks you through your first deploy.
Try it
Create a todo at your live URL, then make sure the next list response contains it.
export APP_URL="https://your-app.tokay.app"
curl -X POST "$APP_URL/todos" \
-H 'Content-Type: application/json' \
-d '{"title":"ship the next thing"}'
curl "$APP_URL/todos"
The item appears while this instance is running. Deploy again and the list returns to its three samples because the starter does not include durable storage.
How it works
You can keep Hono's fetch style handler and Bun start command. Tokay installs from the lockfile, provides PORT, and launches the TypeScript app with Bun.
Secrets
You have no secrets to add. The example talks only to its callers.
Grow from here
Browse the Tokay examples catalog when you want saved data or more than one Service.
Source code
bun.lock Raw
{
"lockfileVersion": 1,
"configVersion": 1,
"workspaces": {
"": {
"name": "tokay-bun-hono-api",
"dependencies": {
"hono": "^4.10.6",
},
},
},
"packages": {
"hono": ["hono@4.12.31", "", {}, "sha512-zJIHFrl6bq3RDd2YusFNCDlM8qUprxKswyi/OPzPyzKDdyBXDqWx8bZlZ7R+saTdSTatUmb3O7K4SspGPaEOQg=="],
}
}
index.ts Raw
import { Hono } from "hono";
const app = new Hono();
const todos = [
{ id: 1, title: "deploy this ✓" },
{ id: 2, title: "add a database" },
{ id: 3, title: "tell a friend" },
];
app.get("/", (context) => context.json({
message: "Hello from Hono",
runtime: `Bun ${Bun.version}`,
}));
app.get("/health", (context) => context.json({ ok: true }));
app.get("/todos", (context) => context.json(todos));
app.post("/todos", async (context) => {
const input = await context.req.json<{ title?: string }>().catch(() => ({}));
const title = String(input.title || "").trim();
if (!title) return context.json({ error: "title is required" }, 400);
const todo = { id: (todos.at(-1)?.id || 0) + 1, title };
todos.push(todo);
return context.json(todo, 201);
});
export default {
port: Number(Bun.env.PORT || 3000),
fetch: app.fetch,
};
package.json Raw
{
"name": "tokay-bun-hono-api",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"start": "bun run index.ts"
},
"engines": {
"bun": ">=1.3.0"
},
"packageManager": "bun@1.3.14",
"dependencies": {
"hono": "^4.10.6"
}
}
Built from revision 259b82f