Prerequisites
- A Sendbaze API key
- A verified domain. A test key works without one, and so does the shared test address for emails to yourself.
- Next.js 14 or later with the App Router
Guide
1
Install
2
Set your API key
.env.local
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
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
@react-email/components, is in React Email.