Send from a Hono route on Node.js 22 or newer with @sendpanda/sdk. On Cloudflare Workers, Bun, Deno or the Edge runtime, call the REST API with fetch instead of the SDK. Do not import the SDK from browser code: the constructor throws when window is defined.
1. Install
npm install @sendpanda/sdk honoCreate a Send emails key and store it as SENDPANDA_API_KEY. The from address has to be on a domain verified in that project. See domain setup. A queued status means the API accepted the email, not that the recipient's server delivered it.
2. Send from a route
import { Hono } from "hono";
import { SendPanda } from "@sendpanda/sdk";
type Env = { SENDPANDA_API_KEY: string };
const app = new Hono<{ Bindings: Env }>();
app.post("/welcome", async (c) => {
const user = await userFromSession(c.req.raw); // your own session
if (!user) return c.json({ error: "Sign in first" }, 401);
const panda = new SendPanda(c.env.SENDPANDA_API_KEY);
const email = await panda.emails.send(
{
from: "Your app <hello@your-verified-domain.com>",
to: [user.email],
subject: "Welcome",
text: "Welcome",
},
{ idempotencyKey: `welcome-${user.id}` },
);
return c.json({ id: email.id, status: email.status });
});
export default app;On Node.js, pass process.env.SENDPANDA_API_KEY instead of c.env. A Worker should POST the same JSON to https://api.sendpanda.email/v1/emails with fetch, and store the key with wrangler secret put SENDPANDA_API_KEY.
A route that sends to any address a request supplies is an open relay. Decide the recipient from your own session or database. Use one idempotency key per business event, and reuse that same key if the request is retried.