Channels
Push
Send Web Push or FCM notifications through a push transport.
Use push for browser Web Push subscriptions or FCM device tokens. The sender passes the target and notification payload to a push transport.
The one rule
Treat subscription endpoints and device tokens as secrets — they are long-lived delivery credentials.
Quick start
import { createPushSender } from "sently/push";
import { WebPushTransport } from "sently/transports/webpush";
const push = createPushSender({
transport: new WebPushTransport({
vapidPublicKey: process.env.VAPID_PUBLIC_KEY!,
vapidPrivateKey: process.env.VAPID_PRIVATE_KEY!,
subject: "mailto:you@example.com",
}),
});// Web Push
await push.send({
subscription: {
endpoint: "https://fcm.googleapis.com/fcm/send/example",
keys: { p256dh: "browser-public-key", auth: "browser-auth-secret" },
},
title: "Report ready",
body: "Your weekly report is ready to view.",
});
// FCM (with FcmTransport)
await push.send({
token: deviceRegistrationToken,
title: "Report ready",
body: "Your weekly report is ready to view.",
});Sender configuration
| Option | Type | Meaning |
|---|---|---|
transport | PushTransport | Required delivery implementation. |
plugins | PushPlugin[] | Optional transforms run before delivery. |
hooks | PushHooks | Optional callbacks for delivery activity. |
Options shapes
PushOptions is a union:
| Shape | Required target | Transport |
|---|---|---|
| Web Push | subscription | WebPushTransport |
| FCM | token | FcmTransport |
Shared fields: title, body, optional data, icon, ttl, messageId.
Troubleshooting
Web Push validates subscription endpoint hosts before sending. Add only exact private relay hostnames with allowedEndpointHosts when needed.
Endpoint paths and FCM tokens are long-lived credentials, so hook context keeps only a redacted fingerprint.