Skip to content

resend/resend-node

Repository files navigation

nodejs-og

Quickstart Docs

Framework guides

Next.js - Remix - Nuxt - Express - RedwoodJS - Hono - Bun - Astro

Resend Node.js SDK

Node.js library for the Resend API.

Install

npm install resend
# or
yarn add resend

Examples

Send email with:

Setup

First, you need to get an API key, which is available in the Resend Dashboard.

import { Resend } from 'resend';
const resend = new Resend('re_xxxx...xxxxxx');

Usage

Send your first email:

await resend.emails.send({
  from: '[email protected]',
  to: '[email protected]',
  replyTo: '[email protected]',
  subject: 'hello world',
  text: 'it works!',
});

Note

In order to send from your own domain, you will first need to verify your domain in the Resend Dashboard.

Send email using HTML

Send an email custom HTML content:

await resend.emails.send({
  from: '[email protected]',
  to: '[email protected]',
  replyTo: '[email protected]',
  subject: 'hello world',
  html: '<strong>it works!</strong>',
});

Send email using React

Start by creating your email template as a React component.

import React from 'react';

export default function EmailTemplate({ firstName, product }) {
  return (
    <div>
      <h1>Welcome, {firstName}!</h1>
      <p>Thanks for trying {product}. We’re thrilled to have you on board.</p>
    </div>
  );
}

Then import the template component and pass it to the react property.

import EmailTemplate from '../components/EmailTemplate';

await resend.emails.send({
  from: '[email protected]',
  to: '[email protected]',
  replyTo: '[email protected]',
  subject: 'hello world',
  react: <EmailTemplate firstName="John" product="MyApp" />,
});

Note

If your endpoint is a JS/TS file, render the template (i.e., pass EmailTemplate({firstName="John", product="MyApp"}) instead of the component).

License

MIT License

About

Resend's Official Node.js SDK

Resources

License

Stars

Watchers

Forks

Packages

No packages published