Sendery
Sendery

Framework Integrations

Next.js integration

Send transactional email from your Next.js server with the Sendery JavaScript SDK.

Install
npm install @sendery/sdk
Source code

Requirements

Use the JavaScript SDK with the App Router on Node.js 22.12+. Publish a welcome template with name and action_url, and create a project API key.

Set the API key

Add the key to .env.local for development or your hosting provider’s secret settings. Keep the variable private; do not prefix it with NEXT_PUBLIC_. Install the server-only marker package with npm install server-only for the helper below.

.env.local
SENDERY_API_KEY=your_project_api_key

Send from the server

Call this helper with await sendWelcome(user, eventKey) from your authenticated signup handler. Use the saved recipient, name, URL, and event key for every retry. The caller should obtain these values from your application’s trusted data.

TypeScript
// lib/send-welcome.ts
import 'server-only';
import { Sendery } from '@sendery/sdk';

type Welcome = { email: string; name: string; actionUrl: string };

export async function sendWelcome(user: Welcome, eventKey: string) {
  const apiKey = process.env.SENDERY_API_KEY;
  if (!apiKey) throw new Error('Set SENDERY_API_KEY on your server.');

  const sendery = new Sendery(apiKey);
  return sendery.prepare({
    to: user.email,
    template: 'welcome',
    data: { name: user.name, action_url: user.actionUrl },
  }, eventKey).retry().send();
}