|
2 | 2 |
|
3 | 3 | > This project is not affiliated or based upon the original [web-push](https://github.com/web-push-libs/web-push) package or [web-push-lib](https://github.com/web-push-libs) organization.
|
4 | 4 |
|
5 |
| -This package is aimed at being a lightweight replacement for [web-push](https://github.com/web-push-libs/web-push), as (at the time of writing) it relies on Node.js dependencies that are not available in the browser. |
| 5 | +Minimal, zero-dependency library for creating and sending Web Push (VAPID) notifications from environments without Node.js crypto shims — for example browsers, Cloudflare Workers, Deno, Bun, and other edge runtimes. |
6 | 6 |
|
7 |
| -## Installation |
| 7 | +Key features: |
| 8 | + |
| 9 | +- Runs in browsers, Cloudflare Workers, Deno, Bun, and Node |
| 10 | +- Zero dependencies; ESM-first and browser-friendly |
| 11 | +- VAPID key generation, serialization/deserialization |
| 12 | +- Payload encryption with aes128gcm (aesgcm partially supported) |
| 13 | +- Helper to generate the correct Web Push request headers and send the POST |
| 14 | + |
| 15 | +Install |
8 | 16 |
|
9 | 17 | ```bash
|
10 | 18 | npm install web-push-browser
|
11 | 19 | ```
|
12 | 20 |
|
13 |
| -## Example Usage |
14 |
| - |
15 |
| -### Subscribing a User |
| 21 | +Quick example — how to send a push notification from an edge runtime or browser environment |
16 | 22 |
|
17 | 23 | ```ts
|
18 | 24 | import { fromBase64Url } from 'web-push-browser';
|
|
38 | 44 | }
|
39 | 45 | ```
|
40 | 46 |
|
41 |
| -### Sending a Push Notification |
| 47 | +## Sending a Push Notification |
42 | 48 |
|
43 | 49 | ```ts
|
44 | 50 | import { sendNotification, deserializeVapidKeys } from 'web-push-browser';
|
@@ -84,4 +90,4 @@ console.log(serializedKeys);
|
84 | 90 | This package only supports the basic functionality. If you need more advanced features, such as proxies, custom headers, etc. you can access the internal functions to create your own requests.
|
85 | 91 |
|
86 | 92 | > [!NOTE]
|
87 |
| -> `aesgcm` is not completely implemented in this package. Please use `aes128gcm` instead. |
| 93 | +> `aesgcm` is not completely implemented in this package. Please use `aes128gcm` instead. |
0 commit comments