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

OptionTypeMeaning
transportPushTransportRequired delivery implementation.
pluginsPushPlugin[]Optional transforms run before delivery.
hooksPushHooksOptional callbacks for delivery activity.

Options shapes

PushOptions is a union:

ShapeRequired targetTransport
Web PushsubscriptionWebPushTransport
FCMtokenFcmTransport

Shared fields: title, body, optional data, icon, ttl, messageId.

Troubleshooting

Learn more

Next

On this page