Quick setup examples
Hono
Send your first email from a Hono route using the senddart SDK.
Send your first email from a Hono app using the senddart SDK. The SDK uses the standard fetch API and works on Node.js, Bun, Cloudflare Workers, and other edge runtimes. Install it with npm install senddart, import SendDart, and call mb.emails.send().
Prerequisites
- A SendDart API key.
- A verified domain to send from.
1. Install the SDK
npm install senddart2. Add your API key
Store your key in the environment. On Node.js or Bun it is available as process.env.SENDDART_API_KEY; on Cloudflare Workers it comes from the request context bindings (c.env).
.env
SENDDART_API_KEY=mb_xxxxxxxxx3. Send email from a route
Create index.ts, instantiate the SDK client, and call mb.emails.send() inside a route handler.
index.ts
import { Hono } from 'hono';
import { SendDart } from 'senddart';
const app = new Hono();
const mb = new SendDart(process.env.SENDDART_API_KEY!);
app.get('/', async (c) => {
const { data, error } = await mb.emails.send({
from: 'Acme <onboarding@yourdomain.com>',
to: ['delivered@test.senddart.com'],
subject: 'hello world',
html: '<strong>it works!</strong>',
});
return c.json(error ? { error } : { data }, error ? 400 : 200);
});
export default app;A successful call returns the created email's
id. See the full request body in the Send an email reference.