Node.js library for the Resend API.
npm install resend
# or
yarn add resend
Send email with:
First, you need to get an API key, which is available in the Resend Dashboard.
import { Resend } from 'resend';
const resend = new Resend('re_123456789');
Send your first email:
await resend.emails.send({
from: 'you@example.com',
to: 'user@gmail.com',
replyTo: 'you@example.com',
subject: 'hello world',
text: 'it works!',
});
Send an email custom HTML content:
await resend.emails.send({
from: 'you@example.com',
to: 'user@gmail.com',
replyTo: 'you@example.com',
subject: 'hello world',
html: '<strong>it works!</strong>',
});
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: 'you@example.com',
to: 'user@gmail.com',
replyTo: 'you@example.com',
subject: 'hello world',
react: <EmailTemplate firstName="John" product="MyApp" />,
});
MIT License