@edgepush/sdk
Official Node/TypeScript SDK for edgepush. Send native iOS and Android push notifications through a single API.
Install
npm install @edgepush/sdk
pnpm add @edgepush/sdk
bun add @edgepush/sdk
Quick start
import { Edgepush } from "@edgepush/sdk";
const client = new Edgepush({
apiKey: "io.akshit.myapp|abc123...",
});
const ticket = await client.send({
to: deviceToken,
title: "Hello",
body: "World",
data: { url: "myapp://home" },
});
const receipt = await client.getReceipt(ticket.id);
console.log(receipt.status);
Batch sends
const tickets = await client.sendBatch([
{ to: token1, title: "Hi", body: "First" },
{ to: token2, title: "Hi", body: "Second" },
]);
const receipts = await client.getReceipts(tickets.map((t) => t.id));
Environments
The SDK is isomorphic. It works in:
- Node.js (>= 18)
- Bun
- Deno
- Cloudflare Workers
- Browsers (CORS allowed, but you should rarely send pushes from a browser)
Error handling
import { Edgepush, EdgepushError } from "@edgepush/sdk";
try {
await client.send({ to: deviceToken, title: "Hi" });
} catch (err) {
if (err instanceof EdgepushError) {
console.error(`edgepush ${err.status}: ${err.code}`);
}
throw err;
}
License
MIT