@towerjs/courier
v0.1.1
Published
Multi-channel communications for Tower — email, SMS, and push notifications
Readme
@towerjs/courier
Multi-channel communication layer for Tower. Send emails (Resend, SES, SMTP), SMS (Twilio), and push notifications (Web Push) through a unified API.
Installation
pnpm add @towerjs/courierUsage
Configure Courier in your tower.config.ts:
import { defineTower } from '@towerjs/blueprint'
export default defineTower({
modules: {
courier: {
email: { provider: 'resend' },
sms: { provider: 'twilio' },
push: { provider: 'web-push' },
},
},
})Send messages:
import { courier } from '@towerjs/tower/courier'
await courier.email.send({
to: '[email protected]',
subject: 'Welcome!',
text: 'Hello from Tower',
})
await courier.sms.send({
to: '+1234567890',
body: 'Your code is 123456',
})Providers
| Provider | Package | Config value |
| -------- | ----------------------- | ------------ |
| Console | (built-in) | "console" |
| Resend | resend | "resend" |
| AWS SES | @aws-sdk/client-sesv2 | "ses" |
| SMTP | nodemailer | "smtp" |
SMS
| Provider | Package | Config value |
| -------- | -------- | ------------ |
| Twilio | twilio | "twilio" |
Push
| Provider | Package | Config value |
| -------- | ---------- | ------------ |
| Web Push | web-push | "web-push" |
React email
Courier renders React email templates natively:
import { courier } from '@towerjs/tower/courier'
import WelcomeEmail from './emails/welcome.tsx'
await courier.email.send({
to: '[email protected]',
subject: 'Welcome!',
react: <WelcomeEmail name="Alice" />,
})Configuration
{
email: {
provider: "resend", // or "ses" | "smtp"
apiKey: process.env.RESEND_API_KEY,
from: "[email protected]",
},
sms: {
provider: "twilio",
accountSid: process.env.TWILIO_ACCOUNT_SID,
authToken: process.env.TWILIO_AUTH_TOKEN,
from: process.env.COURIER_SMS_FROM,
},
}Included in
- @towerjs/tower — meta-package
