Prompt
resend api node example
Latest observation
Oct 19, 2026
OpenAI APIWeb search: off
Here’s a simple Node.js example for sending an email with the Resend API.
1) Install the SDK
npm install resend
2) Example code
import { Resend } from 'resend';
const resend = new Resend('re_YourApiKeyHere');
async function sendEmail() {
try {
const response = await resend.emails.send({
from: 'Acme <onboarding@resend.dev>', // replace with your verified sender
to: ['user@example.com'],
subject: 'Hello from Resend',
html: '<p>This is a test email sent via Resend.</p>',
});
console.log('Email sent:', response);
} catch (error) {
console.error('Error sending email:', error);
}
}
sendEmail();
3) If you're using CommonJS
const { Resend } = require('resend');
const resend = new Resend('re_YourApiKeyHere');
resend.emails.send({
from: 'Acme <onboarding@resend.dev>',
to: ['user@example.com'],
subject: 'Hello from Resend',
html: '<p>This is a test email sent via Resend.</p>',
}).then((response) => {
console.log('Email sent:', response);
}).catch((error) => {
console.error('Error sending email:', error);
});
Notes
- Replace
re_YourApiKeyHerewith your actual Resend API key. - Make sure the
fromaddress is a verified sender in Resend. - You can also use
text:instead ofhtml:if you want plain text.
If you want, I can also give you:
- a Next.js API route example
- a Express route example
- a TypeScript version