Learn how to send your first email using Bun and the Resend Node.js SDK.
bun install resend
email-template.tsx
import * as React from 'react'; interface EmailTemplateProps { firstName: string; } export function EmailTemplate({ firstName }: EmailTemplateProps) { return ( <div> <h1>Welcome, {firstName}!</h1> </div> ); }
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, error } = await resend.emails.send({ from: 'Acme <onboarding@resend.dev>', to: ['delivered@resend.dev'], subject: 'Hello World', react: EmailTemplate({ firstName: 'Vitor' }), }); if (error) { return new Response(JSON.stringify({ error })); } return new Response(JSON.stringify({ data })); }, }); console.log(`Listening on http://localhost:${server.port} ...`);
bun index.tsx
http://localhost:3000
Was this page helpful?