Skip to main content
Every example below is a complete project you can run as-is. Each one needs: The SDKs read BYTESEND_API_KEY from the environment automatically, so you don’t need to pass it in code.

Node.js

package.json
send.js
SDK methods return { data, error } instead of throwing, so always check error before using data.

TypeScript

package.json
send.ts

React Email (TypeScript)

Pass a React Email component as react and the SDK renders it to HTML for you, so no separate render step is needed.
package.json
tsconfig.json
emails/welcome.tsx
send.tsx
react isn’t supported in emails.batch(). For batch sends, render each email first with render() from @react-email/components and pass the result as html.

React Email (JavaScript)

The same project without TypeScript. tsx runs .jsx files directly, so no Babel setup is needed.
package.json
emails/welcome.jsx
send.jsx

Next.js (App Router)

Send from a route handler, and receive webhooks in another. Keep your API key on the server and never import the SDK in a client component.
app/api/welcome/route.ts
app/api/bytesend-webhook/route.ts

Express

server.ts

Safe retries and batches

Pass an idempotency key to make retries safe: sending the same payload with the same key returns the original response instead of sending twice.

Python

send.py
See the Python guide for error handling, idempotency and batches.

Go

main.go
See the Go guide for the full client.