Why edge runtimes excel at transactional email
Cloudflare Workers run in 300+ cities worldwide with zero cold starts. By pairing the ultrafast Hono framework with SadaSend REST endpoints, webhook ingestion and email dispatch execute with sub-10ms latency.
Complete Edge Worker (src/index.ts)
Here is the complete Hono worker deployed to Cloudflare Workers.
import { Hono } from 'hono';
type Bindings = {
SADASEND_API_KEY: string;
};
const app = new Hono<{ Bindings: Bindings }>();
app.post('/api/send-alert', async (c) => {
const body = await c.req.json<{ recipient: string; title: string; details: string }>();
const res = await fetch('https://api.sadasend.com/v1/emails', {
method: 'POST',
headers: {
'Authorization': `Bearer ${c.env.SADASEND_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
to: body.recipient,
subject: `[Alert] ${body.title}`,
text: body.details,
}),
});
const data = await res.json();
return c.json(data, res.status as any);
});
export default app;Deployment in 30 Seconds
Deploy immediately with Wrangler: npx wrangler secret put SADASEND_API_KEY && npx wrangler deploy
Building AI agents that send email?
Join the SadaSend early access waitlist to get scoped API keys, recipient allowlists, and Model Context Protocol (MCP) servers upon launch.