Skip to main content

Prerequisites

Guide

1

Install

2

Set your API key

.env.local
The variable has no NEXT_PUBLIC_ prefix on purpose: the key must only exist on the server.
3

Create a route handler

app/api/send/route.ts
4

Or use a server action

app/actions/send-welcome.ts
5

Try it

Receive webhooks in Next.js

Verify the signature against the raw body before parsing it. The SDK exports the verifier.
app/api/webhooks/sendbaze/route.ts
Route handlers run on the Node.js runtime by default, which is what the SDK expects. It also works on the Edge runtime.

Emails as React components

Install @react-email/render (plus react and react-dom, which Next.js already has) and pass a component as react instead of html. The SDK renders it to HTML and plain text on the server before sending.
app/actions/send-shipped.ts
The full walkthrough, including a component built with @react-email/components, is in React Email.