Next.js Integration
Using the official render25 package inside Next.js App Router, Server Actions, and Edge runtimes.
Installation
Terminal
npm install render25Note
Add your API key to
.env.local as RENDER25_API_KEY=re_live_....App Router Route Handler
app/api/send/route.ts
import { Render25 } from "render25";
import { NextResponse } from "next/server";
const render25 = new Render25(); // Automatically uses process.env.RENDER25_API_KEY
export async function POST(req: Request) {
try {
const { to, subject, html } = await req.json();
const { id } = await render25.emails.send({
from: "notifications@yourdomain.com",
to,
subject,
html,
});
return NextResponse.json({ success: true, id });
} catch (error: any) {
return NextResponse.json({ error: error.message }, { status: 500 });
}
}Server Actions
app/actions/email.ts
"use server";
import { Render25 } from "render25";
const render25 = new Render25();
export async function sendWelcomeEmail(userEmail: string, name: string) {
try {
const result = await render25.emails.send({
from: "welcome@yourdomain.com",
to: userEmail,
subject: `Welcome to the team, ${name}!`,
html: `<h1>Welcome aboard, ${name}</h1><p>We are thrilled to have you.</p>`,
});
return { success: true, messageId: result.id };
} catch (error: any) {
return { success: false, error: error.message };
}
}