Multichannel notifications
A single Notification renders per channel via its toMail / toSlack / toDatabase methods, and notifier.send() fans it out to every channel via() returns — collecting one result per channel. Here email and Slack are simulated; the database channel is real and persists to the feed below (via the ORM).
Tip
Channels are pluggable and their transports injectable: bext ships no SMS provider, so you inject your own (Twilio…). notifier.send() never rejects — each channel returns { ok } or an error without failing the others.
Send a notification
In-app feed (10)
🔔smoke
🔔smoke
🔔smoke
🔔smoke
🔔smoke
🔔smoke
🔔smoke
🔔smoke
🔔smoke
🔔smoke
import { createNotifier, mailChannel, smsChannel, databaseChannel }
from "@bext-stack/framework/notifications";
const notifier = createNotifier([
mailChannel({ appId: "my-site" }), // real: bext SDK email
smsChannel({ send: twilioSend }), // bext has no SMS provider — inject one
databaseChannel({ model: Notifications }), // in-app feed via the ORM
]);
// One Notification renders itself per channel via to<Channel>() methods.
const InvoicePaid = {
via: () => ["mail", "database"],
toMail: (u) => ({ subject: "Paid", html: `<p>Thanks ${u.name}</p>` }),
toDatabase: (u) => ({ type: "invoice.paid", user_id: u.id, read: 0 }),
};
const results = await notifier.send(user, InvoicePaid);
// → { mail: { ok: true }, database: { ok: true, id: "42" } }