Boilerplate-Stack
Back to blog
Articles

Sending Transactional Emails in Next.js with Brevo

|
2 min read

Transactional emails (magic links, payment confirmations, workspace invites, notifications) are critical for any SaaS. Resend is popular, but Brevo (formerly Sendinblue) offers 300 free emails per day, EU GDPR-compliant infrastructure, and a powerful template editor. Here is how to integrate it cleanly in Next.js.

1. Create an account and get the API key

Sign up at brevo.com, create an API key from Settings → API Keys, and store it as BREVO_API_KEY in .env.local. Server-side only.

2. Reusable email service

// lib/email/brevo.ts
export async function sendBrevoEmail({ to, templateId, params }) {
  const response = 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({ to: [{ email: to }], templateId, params }),
  })
  if (!response.ok) throw new Error('Email failed')
}

3. Create templates in Brevo

Brevo lets you store HTML templates in its UI. Each template has a numeric ID. Dynamic variables use {{ params.userName }} syntax. Build templates for: magic link, reset password, payment success, workspace invite.

4. Localize emails

Create one template per locale (e.g., magic-link-en-US and magic-link-fr-FR). In your code, pick the right ID based on the user's locale.

5. Handle errors and rate limits

Brevo caps the free plan at 300 emails/day. For production, wrap sends in a background job (BullMQ or Supabase Edge Functions) with exponential retry. Log every failure for debugging.

6. DKIM and SPF

Configure DKIM and SPF in your DNS to improve deliverability. Brevo generates the records under Senders → Authentication.

Skip 4 hours of email setup. Boilerplate-Stack integrates Brevo natively: pre-configured FR/EN templates, reusable email service, magic link auth, and ready-to-use transactional notifications.

Conclusion

Brevo is a solid Resend alternative for SaaS, with a better free quota and EU hosting. Boilerplate-Stack already wires it in to save you hours of setup.