Decorative background gradient
Back to Blog
Resend Email NextjsReact Email TemplatesNodejs Transactional Email API

Transactional Emails in Next.js with Resend & React Email

Build and send transactional emails in Next.js using React Email components and the Resend API, including domain verification and Server Actions.

Transactional Emails in Next.js with Resend & React Email

Transactional email is deceptively easy to get wrong: inconsistent HTML rendering across clients, spam-folder deliverability, and API keys accidentally exposed client-side are all common failure points. React Email plus Resend solves the first problem with real components instead of hand-written markup, and Resend's API handles delivery — but domain setup and Server Action wiring still need to be done correctly.

Step 1: Install React Email and Resend

bash
bash

Step 2: Build an Email Template as a React Component

tsx

@react-email/components ships pre-built, cross-client-tested primitives (Button, Section, Container) that compile down to table-based, Outlook-compatible HTML automatically — you write normal React and get email-safe markup for free.

Step 3: Preview Templates Locally

json
bash

This starts a local dev server (usually on localhost:3000) that renders every template in emails/ with a live preview and hot reload — check layouts across a few different rendered widths before shipping, since inbox clients vary widely.

Step 4: Verify Your Sending Domain

Before sending anything beyond test emails, verify a domain in the Resend dashboard. Add the SPF, DKIM, and DMARC records it provides to your DNS:

text

Skipping domain verification is the single most common cause of emails landing in spam or failing to deliver at all — an unverified onboarding@resend.dev sender works for testing but shouldn't be used for real transactional traffic.

Step 5: Send the Email from a Server Action

tsx

Passing the React element directly to react is enough — Resend's SDK renders it to HTML server-side internally, so there's no separate @react-email/render call needed in your send path. This only works from server-side code (Server Actions, Route Handlers, background jobs); the API key must never reach the browser.

Step 6: Trigger the Email at the Right Moment

tsx

Step 7: Handle Delivery Failures Gracefully

Don't let an email failure block the user-facing action it's attached to — log it and continue rather than throwing in the critical path.

ts

Key Takeaways

React Email gives you cross-client-safe email markup written as normal React components instead of hand-rolled table HTML, Resend's SDK renders that component directly with no separate render step, domain verification (SPF/DKIM/DMARC) is mandatory for real deliverability, and sending must always happen from server-side code to keep your API key out of the browser.

Frequently Asked Questions

Why use React Email instead of writing raw HTML for emails?

Email HTML has notoriously inconsistent rendering across clients (Outlook, Gmail, Apple Mail), and hand-writing table-based layouts for compatibility is tedious and error-prone. React Email provides pre-built, tested components (Button, Section, Text, etc.) that compile down to compatible HTML/CSS automatically.

Do I need to manually convert my React component to HTML before sending?

No. Resend's Node SDK accepts a React element directly in the react field of its emails.send() call and handles server-side rendering to HTML internally — you don't need @react-email/render as a separate step in your send path.

Why isn't my email arriving or landing in spam?

This is almost always a domain verification issue. Add the SPF, DKIM, and DMARC DNS records Resend provides for your sending domain in the dashboard, and wait for verification to complete before sending production volume — unverified domains have much worse deliverability.

Should I call the Resend API from the client or the server?

Always from the server — a Server Action, Route Handler, or background job. The Resend API key must stay server-side; exposing it in client-side code would let anyone send email through your account.

Working on something similar? Take a look at my services and case studies, or book a free call to talk about your idea.

Related Articles

Caching Strategies and Cache Invalidation — The Complete Guide
CachingSystem DesignPerformance

Caching Strategies and Cache Invalidation — The Complete Guide

A practical guide to caching strategies (cache-aside, write-through, write-behind) and the cache invalidation techniques that keep them from serving stale data.

September 8, 2026Read more →
Database Indexing and Read Replicas — A Practical Guide
DatabasePostgreSQLSystem Design

Database Indexing and Read Replicas — A Practical Guide

How to choose the right database indexes, avoid the ones that quietly hurt write performance, and scale reads with replicas without introducing replication lag bugs.

September 8, 2026Read more →
Load Balancing and Stateless Service Design — A Practical Guide
System DesignLoad BalancingScalability

Load Balancing and Stateless Service Design — A Practical Guide

How load balancers distribute traffic, why stateless services are what actually makes horizontal scaling work, and how to fix the sticky-session traps that quietly reintroduce state.

September 8, 2026Read more →
Session Stores and Database Connection Pooling Explained
BackendRedisDatabase

Session Stores and Database Connection Pooling Explained

Why in-memory sessions break horizontally scaled apps, how to move session state to Redis correctly, and how connection pooling keeps your database from falling over under concurrent load.

September 8, 2026Read more →
Vertical vs Horizontal Scaling: How to Choose and Implement Each
System DesignScalabilityArchitecture

Vertical vs Horizontal Scaling: How to Choose and Implement Each

A practical comparison of vertical and horizontal scaling — what each actually fixes, where each breaks down, and the architecture changes horizontal scaling requires that most guides skip.

September 8, 2026Read more →
AI Agent Guardrails and Safety — Preventing Prompt Injection and Runaway Actions
Ai Agent SafetyPrompt Injection DefenseAgent Guardrails

AI Agent Guardrails and Safety — Preventing Prompt Injection and Runaway Actions

Build practical guardrails for AI agents — prompt injection defenses, destructive-action confirmation, iteration caps, and permission scoping.

September 7, 2026Read more →

Trending Topics