Send email in Next.js with an email API

Add transactional email to a Next.js App Router app with Notify — notifycx SDK or fetch, domain verify, webhooks.

Greenfield guide: add transactional email to a Next.js (App Router) app. You own the HTML; Notify sends it, then you get logs and webhooks. Pro is $10 for 10,000 emails.

Never call Notify from client components — keep NOTIFY_API_KEY on the server.

Prerequisites

1. Install and env

npm install notifycx

.env.local:

NOTIFY_API_KEY=your_api_key_here

2. Send with the SDK (recommended for TypeScript)

// app/api/email/route.ts
import Notify from 'notifycx'
import { NextResponse } from 'next/server'

const notify = new Notify({ apiKey: process.env.NOTIFY_API_KEY! })

export async function POST(req: Request) {
  try {
    const { to, subject, html } = await req.json()
    const data = await notify.send({
      from: 'Acme <noreply@your-verified-domain.com>',
      to,
      subject,
      html
    })
    return NextResponse.json(data)
  } catch (error) {
    return NextResponse.json({ error: String(error) }, { status: 500 })
  }
}

Prefer the html field so agent/Resend-shaped pastes work. message and text are accepted aliases.

3. Or send with fetch

// app/api/email/route.ts
export async function POST(req: Request) {
  try {
    const { to, subject, html } = await req.json()
    const response = await fetch('https://notify.cx/api/email/send', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'x-api-key': process.env.NOTIFY_API_KEY!
      },
      body: JSON.stringify({
        from: 'Acme <noreply@your-verified-domain.com>',
        to,
        subject,
        html
      })
    })

    if (!response.ok) {
      throw new Error(`Failed to send email: ${await response.text()}`)
    }

    return Response.json(await response.json())
  } catch (error) {
    return Response.json({ error: String(error) }, { status: 500 })
  }
}

4. Production checklist

  1. Verify domain — Domain Verification
  2. Send a real message from your custom from
  3. Optional (Pro+): webhooks for delivery / bounce
  4. Inspect logs

5. Common flows

IDE coding agents

Connect notifycx-mcp so Cursor/Claude can call send and list domains while wiring this up. Still put production send in your App Router code as above.

Where to next?