sendsend.email

Send email with Nuxt

A server-side call to the SendSend API from your Nuxt app.

  1. Create a test API key in the dashboard first: it never delivers real email. Switch to a live key once your domain is verified.
  2. Set NUXT_SENDSEND_API_KEY in .env and read it with useRuntimeConfig(event).sendsendApiKey (declare it under runtimeConfig in nuxt.config.ts, private, not public).
  3. Add this to server/api/send.post.ts:
export default defineEventHandler(async (event) => {
  const { to } = await readBody(event);
  const { sendsendApiKey } = useRuntimeConfig(event);
  return await $fetch('https://api.sendsend.email/v1/emails', {
    method: 'POST',
    headers: { Authorization: `Bearer ${sendsendApiKey}`, 'Idempotency-Key': crypto.randomUUID() },
    body: { from: 'Acme <hello@mail.acme.com>', to: [to], subject: 'Hello from Nuxt', html: '<p>It works!</p>' },
  });
});

Good to know