Skip to content
Preview: the PushFleet API isn't live yet. Join the waitlist

TypeScript

The TypeScript SDK calls the API from your server with your secret key. Runs on Node 18 and later, Bun, Deno and Cloudflare Workers.

Terminal window
npm install pushfleet
import { PushFleet } from "pushfleet";

const fleet = new PushFleet(process.env.PUSHFLEET_SECRET_KEY);
await fleet.send({
  to: "user_8f3k",
  title: "Your order shipped",
  body: "Arriving Thursday",
});
await fleet.send({
  to: "user_8f3k",
  template: "order_shipped",
  vars: { eta: "Thu" },
});

In live mode your app registers devices with a user token your server signs. The SDK signs it locally, without a request. See identity verification.

const userToken = fleet.users.token("user_8f3k");

Failed requests throw a PushFleetError with the API’s code, status and doc link. The SDK retries 429 and 5xx responses with backoff, and sends an idempotency key with every retry so nothing goes out twice.

Every endpoint in the API reference has a TypeScript sample.