DEV Community

Alex Spinov
Alex Spinov

Posted on

Deno Deploy Has a Free API You've Never Heard Of

Deno Deploy is a globally distributed JavaScript/TypeScript runtime. It runs your code at the edge in 35+ regions with zero configuration. The free tier gives you 1M requests/month and 100K KV operations — enough for a production API.

What Makes Deno Deploy Special?

  • Free tier — 1M requests/month, 100K KV reads, zero cost
  • Global edge — 35+ regions, sub-50ms response times
  • Zero config — push code, it runs
  • Built-in KV — globally consistent key-value database
  • Cron jobs — scheduled tasks at the edge

The Hidden API: Deno KV

Deno KV is a globally distributed database built into the runtime:

const kv = await Deno.openKv();

// Set values with expiration
await kv.set(['users', 'user123'], {
  name: 'Alice',
  email: 'alice@example.com',
  plan: 'pro'
}, { expireIn: 86400000 }); // 24 hours

// Get values
const user = await kv.get(['users', 'user123']);
console.log(user.value); // { name: 'Alice', ... }

// Atomic transactions
const res = await kv.atomic()
  .check({ key: ['users', 'user123'], versionstamp: user.versionstamp })
  .set(['users', 'user123'], { ...user.value, plan: 'enterprise' })
  .set(['audit', Date.now().toString()], { action: 'upgrade', user: 'user123' })
  .commit();

// List with prefix (great for indexes)
const entries = kv.list({ prefix: ['users'] });
for await (const entry of entries) {
  console.log(entry.key, entry.value);
}
Enter fullscreen mode Exit fullscreen mode

Cron API — Edge Scheduled Tasks

// Run tasks on a schedule at the edge
Deno.cron('daily-cleanup', '0 0 * * *', async () => {
  const old = kv.list({ prefix: ['sessions'] });
  for await (const entry of old) {
    if (isExpired(entry.value)) {
      await kv.delete(entry.key);
    }
  }
});

Deno.cron('hourly-stats', '0 * * * *', async () => {
  const stats = await collectStats();
  await kv.set(['stats', new Date().toISOString()], stats);
});
Enter fullscreen mode Exit fullscreen mode

BroadcastChannel API — Edge Pub/Sub

// Real-time communication across edge instances
const channel = new BroadcastChannel('updates');

channel.onmessage = (event) => {
  console.log('Update from another region:', event.data);
};

// Broadcast to all edge instances
channel.postMessage({ type: 'cache-invalidate', key: 'user:123' });
Enter fullscreen mode Exit fullscreen mode

Quick Start

# Install Deno
curl -fsSL https://deno.land/install.sh | sh

# Create server
echo 'Deno.serve(req => new Response("Hello from the edge!"));' > main.ts

# Deploy
deno deploy --project=myapp main.ts
Enter fullscreen mode Exit fullscreen mode

Why Teams Choose Deno Deploy

A startup founder shared: "We serve 800K requests/day on Deno Deploy's free tier. With KV as our database, our entire backend costs $0. When we hit the limit, the paid tier is $10/mo for 5M requests."


Building edge APIs? Email spinov001@gmail.com or check my developer tools.

Using Deno Deploy? How does it compare to Cloudflare Workers for you?

Top comments (0)