Send email from Next.js
Add one server-side Route Handler that calls the Brevo transactional email API with your key from an environment variable, which keeps the key out of client code.

How it works
import { NextResponse } from "next/server";
export async function POST(request: Request) {
const { to, subject, html } = await request.json();
const res = await fetch("https://api.brevo.com/v3/smtp/email", {
method: "POST",
headers: {
"api-key": process.env.BREVO_API_KEY!,
"Content-Type": "application/json",
},
body: JSON.stringify({
sender: { name: "Your App", email: "[email protected]" },
to: [{ email: to }],
subject,
htmlContent: html,
}),
});
if (!res.ok) {
return NextResponse.json({ error: await res.text() }, { status: res.status });
}
return NextResponse.json({ ok: true });
}
await fetch("/api/send-email", {
method: "POST",
body: JSON.stringify({ to: "[email protected]", subject: "Welcome!", html: "<p>Hi there</p>" }),
});
npm install @getbrevo/brevo
import { BrevoClient } from '@getbrevo/brevo';
const brevo = new BrevoClient({ apiKey: 'your-api-key' });
const result = await brevo.transactionalEmails.sendTransacEmail({
subject: 'Hello from Brevo!',
htmlContent: '<html><body><p>Hello,</p><p>This is my first transactional email.</p></body></html>',
sender: { name: 'Alex from Brevo', email: '[email protected]' },
to: [{ email: '[email protected]', name: 'John Doe' }],
});
console.log('Email sent. Message ID:', result.messageId);
Replace the API key, sender and recipient with your own. Keep keys in environment variables.
Ask your AI agent
Prompts for the Brevo MCP server.
Before I send email from my Next.js app, check that I have a verified sender and an authenticated sending domain. List what is missing.
Read-only: it reads your Brevo account through the Brevo MCP server and changes nothing.
Setup in three steps
Create a key and store it as a secret
Create an API key under SMTP & API, then API keys & MCP. Add it as BREVO_API_KEY in your hosting environment variables, scoped to Production and any other environment that needs it, then redeploy.
Add the Route Handler
Create app/api/send-email/route.ts. It reads to, subject and html from the request body. It posts them to Brevo with the api-key header. Await the fetch call.
Call it and check the log
Post to /api/send-email from your app, then confirm delivery under Transactional, then Email logs. Verify your sender first: unverified senders are rejected or heavily throttled.


