Back to all articles
Next.js & Frameworks March 20, 2026 6 min read

How to Send Transactional Emails in Next.js 15 App Router (TypeScript Guide)

A complete walkthrough of sending transactional emails using Next.js 15 Server Actions and Route Handlers with Sendport.

Sendport Engineering

Sendport Engineering

Developer Relations Team

Sendport Deliverability Team

Introduction

Next.js 15 brings powerful Server Actions and streaming primitives. In this guide, we'll demonstrate how to send transactional emails (such as welcome emails, password resets, and purchase invoices) directly from a Next.js 15 App Router application with sub-20ms latency.

---

Step 1: Configure Your Environment

Sendport provides a high-speed HTTP REST API compatible with any Node.js, Bun, Edge, or Cloudflare Worker runtime without external dependencies.

Add your API key to `.env.local`:


SENDPORT_API_KEY=sk_live_your_api_key_here

---

Step 2: Create a Server Action

Create a new file at `app/actions/send-welcome.ts`:


"use server";

export async function sendWelcomeEmail(toEmail: string, userName: string) { try { const res = await fetch("https://api.getsendport.com/v1/emails/send", { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${process.env.SENDPORT_API_KEY}`, }, body: JSON.stringify({ from: "Acme App ", to: toEmail, subject: `Welcome to Acme, ${userName}!`, html: `

Welcome aboard, ${userName}!

Thank you for signing up. Your account is now active and ready to go.

Go to Your Dashboard →
`, }), });

const data = await res.json(); if (!res.ok) { throw new Error(data.error || "Failed to dispatch email"); }

return { success: true, messageId: data.messageId }; } catch (error: any) { return { success: false, error: error.message }; } }

---

Step 3: Trigger in Your Signup Component


"use client";

import { useState } from "react"; import { sendWelcomeEmail } from "@/app/actions/send-welcome";

export function SignupForm() { const [email, setEmail] = useState(""); const [name, setName] = useState(""); const [status, setStatus] = useState("");

const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setStatus("Sending welcome email..."); const result = await sendWelcomeEmail(email, name); if (result.success) { setStatus("Email sent! Check your inbox."); } else { setStatus("Error: " + result.error); } };

return (

setName(e.target.value)} className="border p-2 rounded w-full" /> setEmail(e.target.value)} className="border p-2 rounded w-full" /> {status &&

{status}

}
); }

---

Conclusion

With Sendport's global edge network, transactional emails dispatch in under 18ms with automated DKIM signing. You get free open/click tracking and webhook delivery out of the box.

#Next.js 15#TypeScript#React Email#Server Actions
High-Throughput Dispatch Engine

Start sending with 99.8% inbox placement today

100 free emails every single day. No credit card required. Instant RSA-2048 DKIM setup.

Create Free Account →