Skip to main content

Use this pre-built prompt to get started faster.

CursorOpen in Cursor

Prerequisites

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

1. Install

Get the Resend Node.js SDK.
bun install resend

2. Create an email template

Start by creating your email template on email-template.tsx.
email-template.tsx
import * as React from 'react';

interface EmailTemplateProps {
  firstName: string;
}

export const EmailTemplate = ({ firstName }: EmailTemplateProps) => (
  <div>
    <h1>Welcome, {firstName}!</h1>
  </div>
);

3. Send email using React

Create a new file index.tsx and send your first email.
index.tsx
import { Resend } from 'resend';
import { EmailTemplate } from './email-template';

const resend = new Resend(process.env.RESEND_API_KEY);

const server = Bun.serve({
  port: 3000,
  async fetch() {
    const data = await resend.emails.send({
      from: 'Acme <onboarding@resend.dev>',
      to: ['delivered@resend.dev'],
      subject: 'Hello World',
      react: EmailTemplate({ firstName: 'Vitor' }),
    });

    return new Response(JSON.stringify(data));
  },
});

console.log(`Listening on http://localhost:${server.port} ...`);
Start the local server by running bun index.tsx and navigate to http://localhost:3000.

3. Try it yourself

Basic Send

Basic email sending

Attachments

Send emails with file attachments

Inline Images (CID)

Embed inline images using CID

Templates

Send emails using Resend hosted templates

Scheduling

Schedule emails for future delivery

Prevent Threading

Prevent email threading on Gmail

Audiences

Manage contacts and audiences

Domains

Create and manage sending domains

Inbound Webhooks

Receive and process inbound emails

Double Opt-in

Double opt-in subscription flow