Getting Started

Quickstart

Send your first email.

Create a client

Pick a provider and pass it to createClient.

import { createClient } from '@nicogenz/emails-sdk';
import { resend } from '@nicogenz/emails-sdk/resend';

const email = createClient({
  provider: resend({ apiKey: process.env.RESEND_API_KEY! }),
});

Send an email

const { id } = await email.send({
  from: 'Acme <[email protected]>',
  to: '[email protected]',
  subject: 'Welcome to Acme',
  html: '<p>Thanks for signing up!</p>',
  text: 'Thanks for signing up!',
});

id is the message ID from the provider.

Handle errors

Every failure throws an EmailError with a normalized code.

import { EmailError } from '@nicogenz/emails-sdk';

try {
  await email.send({
    from: 'Acme <[email protected]>',
    to: '[email protected]',
    subject: 'Welcome to Acme',
    text: 'Thanks for signing up!',
  });
} catch (error) {
  if (error instanceof EmailError) {
    console.error(error.code, error.provider, error.message);
  }
  throw error;
}

Develop without sending

Use the local provider during development. It prints every email to the console instead of sending it.

import { local } from '@nicogenz/emails-sdk/local';

const email = createClient({ provider: local() });
Copyright © 2026