C
CanxJS
v1.6.2
  • Learn
  • Blog
  • Showcase
C
CanxJS

Ultra-fast async MVC backend framework for Bun. Build production-ready APIs with elegance and speed.

Resources

  • Documentation
  • Learn
  • Blog
  • Showcase

Documentation

  • Introduction
  • Installation
  • Core Concepts
  • CLI Commands
  • API Reference

Legal

  • Privacy Policy
  • Terms of Service

© 2026 CanxJS. All rights reserved.

Built with ❤️ for Candra Kirana

  • WebSockets
  • Task Scheduling
  • Queues
  • Job Batches
  • Caching
  • Events
  • Broadcasting
  • Notifications
  • SMS Channels
  • File Storage
  • Payment
  • Search
  • Security
  • Security Comparison
  • Performance
  • HTTP/2 Support
  • Deployment
Notifications

SMS Channels

Send SMS notifications easily using Twilio, Vonage, or custom drivers. Integrated seamlessly with CanxJS's notification system.

Configuration

Configure your SMS drivers in the app config.

src/config/app.ts
1// src/config/app.ts
2export const config = {
3 // ...
4 sms: {
5 default: 'twilio',
6 drivers: {
7 twilio: {
8 sid: process.env.TWILIO_SID,
9 token: process.env.TWILIO_TOKEN,
10 from: process.env.TWILIO_FROM,
11 },
12 vonage: {
13 key: process.env.VONAGE_KEY,
14 secret: process.env.VONAGE_SECRET,
15 from: process.env.VONAGE_FROM,
16 }
17 }
18 }
19};

Sending via Notification

The recommended way to send SMS is through Notification classes. Simply add sms to the via array and implement toSms.

notifications/OrderShipped.ts
1import { Notification, type Notifiable } from 'canxjs';
2
3export class OrderShipped extends Notification {
4 constructor(public orderId: string) {}
5
6 via(notifiable: Notifiable) {
7 return ['sms'];
8 }
9
10 toSms(notifiable: Notifiable) {
11 return {
12 content: `Your order ${this.orderId} has been shipped!`,
13 // Optional: override recipient
14 // to: '+1234567890'
15 };
16 }
17}

Direct Usage

You can also use the sms facade for quick, direct messaging.

controller.ts
1import { sms } from 'canxjs';
2
3// Send using default driver
4await sms().send({
5 to: '+15550001234',
6 content: 'Hello form CanxJS!'
7});
8
9// Switch driver
10await sms().driver('vonage').send({
11 to: '+15550001234',
12 content: 'Hello from Vonage!'
13});

More Notifications