Learn how to send your first email using Redwood.js and the Resend Node.js SDK.
yarn workspace api add resend
yarn rw g function send
html
import { Resend } from 'resend'; import type { APIGatewayEvent, Context } from 'aws-lambda'; const resend = new Resend('re_xxxxxxxxx'); export const handler = async (event: APIGatewayEvent, context: Context) => { const { data, error } = await resend.emails.send({ from: 'Acme <onboarding@resend.dev>', to: ['delivered@resend.dev'], subject: 'hello world', html: '<strong>it works!</strong>', }); if (error) { return { statusCode: 500, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ error }), }; } return { statusCode: 200, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ data }), }; };
Was this page helpful?