Deno Deploy is the fastest way to get a TypeScript API online. Write code, push, it is live globally in seconds.
What is Deno Deploy?
Deno Deploy is a globally distributed platform for serverless JavaScript and TypeScript. Your code runs on the edge — in 35+ regions worldwide.
Quick Start
// main.ts
Deno.serve((req: Request) => {
const url = new URL(req.url);
if (url.pathname === "/api/hello") {
return Response.json({ message: "Hello from the edge!" });
}
return new Response("Not Found", { status: 404 });
});
# Deploy instantly
deno deploy --project=my-app main.ts
Your API is live at https://my-app.deno.dev
With Hono (Recommended)
import { Hono } from "https://deno.land/x/hono/mod.ts";
const app = new Hono();
app.get("/", (c) => c.json({ status: "ok" }));
app.get("/users/:id", async (c) => {
const id = c.req.param("id");
// Use Deno KV for storage
const kv = await Deno.openKv();
const user = await kv.get(["users", id]);
if (!user.value) return c.json({ error: "Not found" }, 404);
return c.json(user.value);
});
app.post("/users", async (c) => {
const body = await c.req.json();
const kv = await Deno.openKv();
const id = crypto.randomUUID();
await kv.set(["users", id], { id, ...body });
return c.json({ id, ...body }, 201);
});
Deno.serve(app.fetch);
Built-in Deno KV (No External Database)
const kv = await Deno.openKv();
// Globally consistent storage
await kv.set(["visits", "total"], 0);
Deno.serve(async (req) => {
const key = ["visits", "total"];
// Atomic increment
await kv.atomic()
.sum(key, 1n)
.commit();
const result = await kv.get(key);
return Response.json({ visits: Number(result.value) });
});
Cron Jobs
Deno.cron("daily-cleanup", "0 0 * * *", async () => {
const kv = await Deno.openKv();
const entries = kv.list({ prefix: ["temp"] });
for await (const entry of entries) {
await kv.delete(entry.key);
}
console.log("Cleanup complete");
});
BroadcastChannel (Real-time)
const channel = new BroadcastChannel("chat");
Deno.serve((req) => {
if (req.headers.get("upgrade") === "websocket") {
const { socket, response } = Deno.upgradeWebSocket(req);
socket.onmessage = (e) => {
channel.postMessage(e.data);
};
channel.onmessage = (e) => {
socket.send(e.data);
};
return response;
}
return new Response("WebSocket only");
});
Free Tier
- 100,000 requests/day
- 1 GB outbound bandwidth/month
- Deno KV included
- Custom domains
- GitHub integration
Deno Deploy vs Alternatives
| Feature | Deno Deploy | Cloudflare Workers | Vercel Edge |
|---|---|---|---|
| Language | TS/JS | TS/JS | TS/JS |
| KV Store | Deno KV (free) | KV ($5/mo) | Edge Config |
| Cron | Built-in | Cron Triggers | Vercel Cron |
| Cold Start | ~0ms | ~0ms | ~50ms |
| Free Requests | 100K/day | 100K/day | 100K/day |
| Deploy Speed | Instant | Fast | Medium |
Need edge-deployed data extraction? Check out my Apify actors — globally distributed scraping. For custom solutions, email spinov001@gmail.com.
Top comments (0)