Prerequisites

To get the most out of this guide, you’ll need to:

1. Install

Get the Resend Node.js SDK.
npm install resend

2. Send email using HTML

Create a +server API route under src/routes/send/+server.ts. The easiest way to send an email is by using the html parameter.
import { Resend } from 'resend';
import { RESEND_API_KEY } from '$env/static/private'; // define in your .env file

const resend = new Resend(RESEND_API_KEY);

export async function POST() {
  try {
    const { data, error } = await resend.emails.send({
      from: 'Acme <onboarding@resend.dev>',
      to: ['delivered@resend.dev'],
      subject: 'Hello world',
      html: '<p>Hello world</p>',
    });

    if (error) {
      return Response.json({ error }, { status: 500 });
    }

    return Response.json({ data });
  } catch (error) {
    return Response.json({ error }, { status: 500 });
  }
}

3. Try it yourself