Sendery
Sendery

Framework Integrations

Nuxt integration

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

Install
npm install @sendery/[email protected]
Source code

Requirements

Use the JavaScript SDK with a Node.js 22.12+ server runtime. Create a project API key.

Configure a private key

Add senderyApiKey to runtimeConfig, outside runtimeConfig.public.

nuxt.config.ts
// nuxt.config.ts
export default defineNuxtConfig({
  runtimeConfig: { senderyApiKey: '' },
});

Set the environment variable

Set NUXT_SENDERY_API_KEY in your server environment. Nuxt maps it to runtimeConfig.senderyApiKey.

Environment
NUXT_SENDERY_API_KEY=your_project_api_key

Send from the server

Call sendEmail(event, input, emailKey) from your server code. Pass the recipient, published template key, and variables in input. Reuse emailKey and the same input when retrying.

TypeScript
// server/utils/sendEmail.ts
import { Sendery, type SendEmailInput } from '@sendery/sdk';
import type { H3Event } from 'h3';

export async function sendEmail(event: H3Event, input: SendEmailInput, emailKey: string) {
  const config = useRuntimeConfig(event);
  const sendery = new Sendery(config.senderyApiKey);
  return sendery.prepare(input, emailKey).retry().send();
}

Send a specific version

Choose a published template version to keep sending it after newer versions are published. By default, Sendery uses the latest version.

TypeScript
// server/utils/sendEmail.ts
import { Sendery, type SendEmailInput } from '@sendery/sdk';
import type { H3Event } from 'h3';

export async function sendEmail(event: H3Event, input: SendEmailInput, emailKey: string) {
  const config = useRuntimeConfig(event);
  const sendery = new Sendery(config.senderyApiKey);
  return sendery.prepare(input, emailKey).version(3).send();
}

Attachments

Use attachment() in your server route to include files in a send. The helper handles base64 encoding.

Send up to 10 files totaling 5 MB. See the attachment reference for supported formats and limits.

Example
import { Sendery, attachment } from '@sendery/sdk';
import { readFile } from 'node:fs/promises';

const sendery = new Sendery(process.env.SENDERY_API_KEY);
const file = await readFile('/path/document.pdf');

await sendery.prepare({
    to: '[email protected]',
    template: 'your-template',
    data: { name: 'Alex', action_url: 'https://example.com/start' },
    attachments: [attachment('document.pdf', file, 'application/pdf')],
}, 'your-idempotency-key').retry().send();