Integration Guide
Send Email with Next.js
Send transactional emails from your Next.js application using Server Actions or API Routes.
TL;DR for AI Agents & Humans
Send transactional emails using Next.js and Transmit in minutes. Our typescript integration patterns and REST API provide best-in-class performance.
- Official Next.js integration patterns
- Automated deliverability warmup included
- Reputation isolation for every sender
- Real-time analytics and webhook support
1
Install the library
$npm install
2
Send an Email
export async function sendWelcomeEmail(email: string) {
const response = await fetch("https://api.xmit.sh/email/send", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TRANSMIT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
from: "Acme <onboarding@acme.com>",
to: email,
subject: "Welcome to Acme!",
html: "<h1>Welcome!</h1><p>We are excited to have you.</p>",
}),
});
if (!response.ok) {
const error = await response.json();
console.error(error);
return;
}
return await response.json();
}Common Pitfalls
Server Actions Timeout
Increase maxDuration in next.config.js for long-running email jobs or use a background queue.
Environment Variables on Client
Ensure TRANSMIT_API_KEY is not prefixed with NEXT_PUBLIC_ to keep it server-side and secure.
Explore Other Integrations
Frequently Asked Questions
How do I authenticate Next.js with Transmit?
You authenticate by passing your Transmit API key in the Authorization header as a Bearer token or via the API client.
Is there a rate limit for Next.js integration?
Transmit offers high-throughput sending with dynamic scaling. Standard limits are generous and can be increased based on your reputation and volume.