Notification
Resend
Email notification provider powered by Resend.
Email notification provider for CommerceJS, powered by Resend.
Installation
pnpm add @commercejs/notification-resend resend
Quick Start
import { createCommerce } from '@commercejs/core'
import { createResendProvider } from '@commercejs/notification-resend'
const resend = createResendProvider({
apiKey: 're_...',
from: 'My Store <noreply@mystore.com>',
replyTo: 'support@mystore.com', // optional
})
const commerce = createCommerce({
adapter,
notifications: { resend },
notificationRules: [
{
event: 'order.created',
channel: 'email',
provider: 'resend',
template: 'order_confirmation',
buildMessage: (payload) => ({
to: payload.order.customer.email,
subject: `Order #${payload.order.id} confirmed`,
data: { order: payload.order },
}),
},
],
})
Configuration
| Option | Type | Required | Description |
|---|---|---|---|
apiKey | string | ✅ | Resend API key |
from | string | ✅ | Default sender (e.g. "Store <noreply@example.com>") |
replyTo | string | — | Reply-to address for all emails |
client | Resend | — | Custom Resend client instance (overrides apiKey) |
Supported Channels
| Channel | Supported |
|---|---|
email | ✅ |
sms | ❌ |
push_web | ❌ |
push_mobile | ❌ |
whatsapp | ❌ |
telegram | ❌ |
How It Works
- Register the provider in
createCommerce()undernotifications - Define notification rules that map commerce events to email deliveries
- When an event fires (e.g.
order.created), the rule'sbuildMessage()builds the email - The provider sends via Resend's API and returns
{ success, messageId }or{ success: false, error }
Templates
Pass a template field in your notification rule to use Resend template IDs. The template ID is sent as a custom X-Template-Id header.
Error Handling
The provider never throws — all errors are caught and returned as { success: false, error: string }:
- Invalid channel → immediately rejected
- Missing recipient → immediately rejected
- Resend API error → error message from Resend
- Network error → exception message