Node.js
Express

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

The easiest way to send an email is by using the html parameter.

server.ts
import express, { Request, Response } from "express";
import { Resend } from "resend";

const app = express();
const resend = new Resend("re_123456789");

app.get("/", async (req: Request, res: Response) => {
  try {
    const data = await resend.sendEmail({
      from: "from@example.com",
      to: "to@example.com",
      subject: "hello world",
      html: "<strong>it works!</strong>",
    });
    res.status(200).json({ data });
  } catch (error) {
    res.status(500).json({ error });
  }
});

app.listen(3000, () => {
  console.log("Listening on http://localhost:3000");
});

3. Try it yourself

Express Example

See the full source code.