Skip to main content
Home
This release is 1 version behind 0.3.1 — the latest version of @upyo/resend. Jump to latest

@upyo/resend@0.3.0-dev.36+e7618f03
Built and signed on GitHub Actions

Resend transport for Upyo email library

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
2 months ago (0.3.0-dev.36+e7618f03)
class ResendTransport
implements Transport

Resend transport implementation for sending emails via Resend API.

This transport provides efficient email delivery using Resend's HTTP API, with support for authentication, retry logic, batch sending capabilities, and idempotency for reliable delivery.

Examples

Example 1

import { ResendTransport } from '@upyo/resend';

const transport = new ResendTransport({
  apiKey: 'your-resend-api-key',
  timeout: 30000,
  retries: 3
});

const receipt = await transport.send(message);
if (receipt.successful) {
  console.log('Message sent with ID:', receipt.messageId);
} else {
  console.error('Send failed:', receipt.errorMessages.join(', '));
}

Constructors

new
ResendTransport(config: ResendConfig)

Creates a new Resend transport instance.

Properties

The resolved Resend configuration used by this transport.

private
httpClient: ResendHttpClient

Methods

private
canUseBatchApi(messages: Message[]): boolean

Checks if messages can use Resend's batch API.

Batch API limitations:

  • No attachments
  • No tags
  • No scheduled sending
private
chunkArray<T>(
array: T[],
size: number,
): T[][]

Splits an array into chunks of specified size.

send(
message: Message,
options?: TransportOptions,
): Promise<Receipt>

Sends a single email message via Resend API.

This method converts the message to Resend format, makes an HTTP request to the Resend API with automatic idempotency key generation, and returns a receipt with the result.

private
sendBatch(
messages: Message[],
options?: TransportOptions,
): AsyncIterable<Receipt>

Sends a batch of messages using Resend's batch API.

sendMany(
messages: Iterable<Message> | AsyncIterable<Message>,
options?: TransportOptions,
): AsyncIterable<Receipt>

Sends multiple email messages efficiently via Resend API.

This method intelligently chooses between single requests and batch API based on message count and features used. For optimal performance:

  • Uses batch API for ≤100 messages without attachments or tags
  • Falls back to individual requests for messages with unsupported features
  • Chunks large batches (>100) into multiple batch requests
private
sendManyOptimized(
messages: Message[],
options?: TransportOptions,
): AsyncIterable<Receipt>

Optimized batch sending that chooses the best strategy based on message features.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@upyo/resend

Import symbol

import { ResendTransport } from "@upyo/resend";
or

Import directly with a jsr specifier

import { ResendTransport } from "jsr:@upyo/resend";

Add Package

pnpm i jsr:@upyo/resend
or (using pnpm 10.8 or older)
pnpm dlx jsr add @upyo/resend

Import symbol

import { ResendTransport } from "@upyo/resend";

Add Package

yarn add jsr:@upyo/resend
or (using Yarn 4.8 or older)
yarn dlx jsr add @upyo/resend

Import symbol

import { ResendTransport } from "@upyo/resend";

Add Package

vlt install jsr:@upyo/resend

Import symbol

import { ResendTransport } from "@upyo/resend";

Add Package

npx jsr add @upyo/resend

Import symbol

import { ResendTransport } from "@upyo/resend";

Add Package

bunx jsr add @upyo/resend

Import symbol

import { ResendTransport } from "@upyo/resend";