@commercejs/notification-resend
v0.2.2
Published
Resend email notification provider for CommerceJS
Readme
@commercejs/notification-resend
Resend email notification provider for CommerceJS.
Overview
@commercejs/notification-resend implements the NotificationProvider interface using Resend for email delivery. Register it in createCommerce() with notification rules to send emails on commerce events (order confirmations, shipping updates, etc.).
Install
npm install @commercejs/notification-resend resendQuick Start
import { createCommerce } from '@commercejs/core'
import { createResendProvider } from '@commercejs/notification-resend'
const commerce = createCommerce({
adapter,
notifications: {
resend: createResendProvider({
apiKey: 're_...',
from: 'My Store <[email protected]>',
}),
},
notificationRules: [
{
event: 'order.created',
channel: 'email',
provider: 'resend',
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 | ✅ | Sender address (e.g. "Store <[email protected]>") |
| replyTo | string | — | Reply-to address for all emails |
| client | Resend | — | Custom Resend client (overrides apiKey) |
Supported Channels
This provider supports the email channel only. Attempts to send through other channels (sms, push_web, etc.) return { success: false, error }.
Error Handling
The provider never throws. All errors are returned as { success: false, error: string }:
- Unsupported channel → rejected immediately
- Missing recipient → rejected immediately
- Resend API error → error message from Resend
- Network/runtime error → exception message
Exports
| Export | Type | Description |
|---|---|---|
| createResendProvider | Function | Create a Resend-backed notification provider |
| ResendProviderConfig | Type | Configuration interface |
Documentation
Full docs at commerce.js.org
