Integration

Send Email from Next.js with NoticeAPI

NoticeAPI fits Next.js apps that need product email from route handlers, Server Actions, auth flows, or webhook jobs. Keep the API key server-side, send through the Node runtime, and start with sandbox or simulator addresses before production DNS is verified.

app/api/receipts/route.ts
import { NoticeAPI } from "noticeapi";

export const runtime = "nodejs";

const notice = new NoticeAPI(process.env.NOTICEAPI_KEY!);

export async function POST(request: Request) {
  const { email, orderId, firstName } = await request.json();

  const result = await notice.emails.send(
    {
      from: "Acme Billing <[email protected]>",
      to: email,
      subject: `Receipt #${orderId}`,
      html: `<p>Hi ${firstName}, thanks for your order.</p>`,
    },
    { idempotencyKey: `receipt-${orderId}` },
  );

  return Response.json({ id: result.id });
}

App Router friendly

Call the SDK from route handlers, Server Actions, or webhook handlers that run on the server.

Server-side secret

Keep NOTICEAPI_KEY in server environment variables. Do not expose ntc_ keys to client components.

Simulator first

Send from [email protected] to simulator recipients while developing and testing.

Webhook-ready receipts

Use order, job, or payment event ids as idempotency keys so retries do not duplicate customer email.

How it works

From test send to production traffic.

1

Install the SDK

Run npm install noticeapi in your Next.js project.

2

Store the API key server-side

Add NOTICEAPI_KEY to your server environment and read it only from server code.

3

Send from a route handler

Use the Node runtime for the handler and pass an idempotency key for retry-safe sends.

4

Move from sandbox to production

Use simulator recipients during development, then verify your sending domain for real traffic.

Trust

Next.js email belongs on the server

NoticeAPI keys authenticate real sends, so the integration should live in route handlers, Server Actions, or backend jobs. Client components should call your app, not NoticeAPI directly.

Implementation links

Build with the shipped docs.

FAQ

Questions developers ask before switching email.

Can I call NoticeAPI from a Client Component?

No. Keep the ntc_ API key server-side. Have the Client Component call your own route handler or Server Action.

Should I use the Edge runtime?

Use the Node runtime for the standard SDK path. You can call the REST API yourself from other server runtimes if they support fetch and secure environment variables.

How should I send Stripe receipt emails?

Send from your webhook handler after verifying the Stripe event, and use the event id or invoice id as the NoticeAPI idempotency key.

Start free. Send production after your domain is ready.

Free includes 3,000 production emails per month, a 100/day production cap, and one verified sending domain.