Quick setup examples

Nuxt

Send your first email from a Nuxt server route using the senddart SDK.

Send your first email from a Nuxt app using the senddart Node SDK. Install it with npm install senddart, then import SendDart and call mb.emails.send(). A Nuxt server route keeps the key on the server, where it belongs.

Prerequisites

1. Install the SDK

npm install senddart

2. Add your API key

Store your key in .env. Nuxt reads it server-side from process.env.

.env
SENDDART_API_KEY=mb_xxxxxxxxx

3. Send email from a server route

Create a server route under server/api/send.ts. Instantiate the SDK client with the key from process.env and call mb.emails.send().

server/api/send.ts
import { SendDart } from 'senddart';

const mb = new SendDart(process.env.SENDDART_API_KEY!);

export default defineEventHandler(async () => {
  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>',
  });

  if (error) {
    throw createError({ statusCode: 500, message: 'Error sending email' });
  }

  return data;
});
A successful call returns the created email's id. See the full request body in the Send an email reference.