Integration
Send emails from Bun with Postkit
Send transactional emails from Bun with native fetch. Fast startup, zero config.
1. Set your API key
# .env POSTKIT_API_KEY=pk_live_...
2. Send an email
typescript
// server.ts
Bun.serve({
port: 3000,
async fetch(req) {
if (req.method !== "POST") {
return new Response("Method not allowed", { status: 405 });
}
const { to, name } = await req.json();
const res = await fetch("https://api.postkit.eu/v1/emails", {
method: "POST",
headers: {
Authorization: `Bearer ${Bun.env.POSTKIT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
from: "hello@yourapp.eu",
to,
subject: "Welcome aboard!",
html: `<h1>Welcome, ${name}!</h1>`,
}),
});
return new Response(JSON.stringify(await res.json()), {
headers: { "Content-Type": "application/json" },
});
},
});3. Handle webhooks
Postkit sends delivery events (sent, delivered, bounced, opened, clicked) via HMAC-SHA256 signed webhooks following the Standard Webhooks specification.
typescript
// Same HMAC verification pattern as Node.js — Bun supports
// the crypto module natively.