|
1 | | -# PushForge 🚀 |
2 | | - |
3 | 1 | <div align="center"> |
4 | 2 |
|
5 | | -<img src="images/pushforge_logo.png" alt="PushForge Logo" width="150" /> |
| 3 | +<img src="images/logo.webp" alt="PushForge Logo" width="120" /> |
| 4 | + |
| 5 | +# PushForge |
6 | 6 |
|
7 | | -**Modern, Cross-Platform Web Push Notifications** |
| 7 | +**Web Push Notifications for the Modern Stack** |
8 | 8 |
|
| 9 | +[](https://www.npmjs.com/package/@pushforge/builder) |
9 | 10 | [](https://opensource.org/licenses/MIT) |
10 | | -[](https://nodejs.org/) |
11 | | -[](CONTRIBUTING.md) |
| 11 | +[](https://www.typescriptlang.org/) |
12 | 12 |
|
13 | | -</div> |
| 13 | +Zero dependencies · Works everywhere · TypeScript-first |
14 | 14 |
|
15 | | -## What is PushForge? |
| 15 | +[Documentation](packages/builder) · [npm](https://www.npmjs.com/package/@pushforge/builder) · [Report Bug](https://github.com/draphy/pushforge/issues) |
16 | 16 |
|
17 | | -PushForge is a comprehensive toolkit for implementing Web Push Notifications in modern web applications. It handles the complex parts of push notifications so you can focus on building great user experiences. |
| 17 | +**[Try the Live Demo →](https://pushforge.draphy.org)** |
18 | 18 |
|
19 | | -**Zero dependencies. Cross-platform. TypeScript-first.** |
| 19 | +</div> |
20 | 20 |
|
21 | | -### Features |
| 21 | +--- |
22 | 22 |
|
23 | | -- 🔐 Compliant VAPID authentication |
24 | | -- 📦 Streamlined payload encryption |
25 | | -- 🌐 Works everywhere: Node.js, Browsers, Deno, Bun, Cloudflare Workers |
26 | | -- 🧩 Modular architecture for flexible implementation |
27 | | -- 🛠️ Built with TypeScript for robust type safety |
| 23 | +## Live Demo |
28 | 24 |
|
29 | | -## Packages |
| 25 | +See PushForge in action at **[pushforge.draphy.org](https://pushforge.draphy.org)** — a fully working test site powered by PushForge on Cloudflare Workers. |
30 | 26 |
|
31 | | -| Package | Description | Path | |
32 | | -| -------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------- | |
33 | | -| [@pushforge/builder](packages/builder) | Core library for building push notification requests with proper VAPID encryption | [`packages/builder/`](packages/builder) | |
| 27 | +- **Enable push notifications** on your device with a single toggle |
| 28 | +- **Send a test notification** to all active devices — anyone visiting the page can send and receive |
| 29 | +- **See it working across browsers** — Chrome, Firefox, Edge, Safari 16+, and more |
| 30 | +- Subscriptions auto-expire after 5 minutes — no permanent data stored |
34 | 31 |
|
35 | | -_More packages coming soon!_ |
| 32 | +The entire backend is a single Cloudflare Worker using `buildPushHTTPRequest()` from `@pushforge/builder` with zero additional dependencies. |
36 | 33 |
|
37 | | -## Quick Start |
| 34 | +## The Problem |
38 | 35 |
|
39 | | -```bash |
40 | | -# Install the core package |
41 | | -npm install @pushforge/builder |
| 36 | +Traditional web push libraries like `web-push` rely on Node.js-specific APIs that don't work in modern edge runtimes: |
42 | 37 |
|
43 | | -# Generate VAPID keys for push authentication |
44 | | -npx @pushforge/builder generate-vapid-keys |
| 38 | +``` |
| 39 | +❌ Cloudflare Workers - "crypto.createECDH is not a function" |
| 40 | +❌ Vercel Edge - "https.request is not available" |
| 41 | +❌ Convex - "Top-level await is not supported" |
45 | 42 | ``` |
46 | 43 |
|
47 | | -Check out the complete documentation in each package's README for detailed usage examples. |
| 44 | +## The Solution |
48 | 45 |
|
49 | | -## Project Structure |
| 46 | +PushForge uses standard Web APIs that work everywhere: |
50 | 47 |
|
51 | | -``` |
52 | | -pushforge/ |
53 | | -├── packages/ |
54 | | -│ └── builder/ # Core push notification builder |
55 | | -│ ├── lib/ # Source code |
56 | | -│ ├── examples/ # Usage examples (coming soon...) |
57 | | -│ └── README.md # Package documentation |
58 | | -└── README.md # This file |
59 | | -``` |
| 48 | +```typescript |
| 49 | +import { buildPushHTTPRequest } from "@pushforge/builder"; |
60 | 50 |
|
61 | | -## Requirements |
| 51 | +const { endpoint, headers, body } = await buildPushHTTPRequest({ |
| 52 | + privateJWK: VAPID_PRIVATE_KEY, |
| 53 | + subscription: userSubscription, |
| 54 | + message: { |
| 55 | + payload: { title: "Hello!", body: "This works everywhere." }, |
| 56 | + adminContact: "mailto:admin@example.com" |
| 57 | + } |
| 58 | +}); |
62 | 59 |
|
63 | | -- **Node.js**: v16.0.0 or higher (for WebCrypto API support) |
64 | | -- **NPM**, **Yarn**, or **pnpm** for package management |
| 60 | +await fetch(endpoint, { method: "POST", headers, body }); |
| 61 | +``` |
65 | 62 |
|
66 | | -## Development Setup |
| 63 | +## Why PushForge? |
67 | 64 |
|
68 | | -1. Clone the repository: |
| 65 | +| | PushForge | web-push | |
| 66 | +|---|:---:|:---:| |
| 67 | +| Dependencies | **0** | 5+ | |
| 68 | +| Cloudflare Workers | ✅ | [❌](https://github.com/web-push-libs/web-push/issues/718) | |
| 69 | +| Vercel Edge | ✅ | ❌ | |
| 70 | +| Convex | ✅ | ❌ | |
| 71 | +| Deno / Bun | ✅ | Limited | |
| 72 | +| TypeScript | Native | @types | |
69 | 73 |
|
70 | | - ```bash |
71 | | - git clone https://github.com/draphy/pushforge.git |
72 | | - cd pushforge |
73 | | - ``` |
| 74 | +## Quick Start |
74 | 75 |
|
75 | | -2. Install dependencies: |
| 76 | +```bash |
| 77 | +# Install |
| 78 | +npm install @pushforge/builder |
76 | 79 |
|
77 | | - ```bash |
78 | | - pnpm install |
79 | | - ``` |
| 80 | +# Generate VAPID keys |
| 81 | +npx @pushforge/builder vapid |
| 82 | +``` |
80 | 83 |
|
81 | | -3. Build packages: |
| 84 | +**Frontend** - Subscribe users: |
82 | 85 |
|
83 | | - ```bash |
84 | | - pnpm build |
85 | | - ``` |
| 86 | +```javascript |
| 87 | +const subscription = await registration.pushManager.subscribe({ |
| 88 | + userVisibleOnly: true, |
| 89 | + applicationServerKey: VAPID_PUBLIC_KEY |
| 90 | +}); |
| 91 | +// Send subscription.toJSON() to your server |
| 92 | +``` |
86 | 93 |
|
87 | | -4. Available Commands: |
| 94 | +**Backend** - Send notifications: |
88 | 95 |
|
89 | | - ```bash |
90 | | - # Format and lint code |
91 | | - pnpm biome:format # Format code with Biome |
92 | | - pnpm biome:lint # Lint code with Biome |
93 | | - pnpm biome:check # Check code with Biome |
94 | | - pnpm biome:fix # Fix issues automatically with Biome |
| 96 | +```typescript |
| 97 | +import { buildPushHTTPRequest } from "@pushforge/builder"; |
95 | 98 |
|
96 | | - # Type checking |
97 | | - pnpm type:check # Run TypeScript type checking |
| 99 | +const { endpoint, headers, body } = await buildPushHTTPRequest({ |
| 100 | + privateJWK: process.env.VAPID_PRIVATE_KEY, |
| 101 | + subscription, |
| 102 | + message: { |
| 103 | + payload: { title: "New Message", body: "You have a notification!" }, |
| 104 | + adminContact: "mailto:admin@example.com" |
| 105 | + } |
| 106 | +}); |
98 | 107 |
|
99 | | - # Commit checks (run before committing) |
100 | | - pnpm commit:check # Run formatting, type checking and build |
101 | | - ``` |
| 108 | +await fetch(endpoint, { method: "POST", headers, body }); |
| 109 | +``` |
102 | 110 |
|
103 | | -## Contributing |
| 111 | +See the [full documentation](packages/builder) for platform-specific examples (Cloudflare Workers, Vercel Edge, Convex, Deno, Bun). |
104 | 112 |
|
105 | | -Contributions are always welcome! We follow a structured workflow for contributions - see our [Contributing Guidelines](CONTRIBUTING.md) for details. |
| 113 | +## Packages |
106 | 114 |
|
107 | | -Whether you want to: |
| 115 | +| Package | Description | |
| 116 | +|---------|-------------| |
| 117 | +| [@pushforge/builder](packages/builder) | Core library for building push notification requests | |
108 | 118 |
|
109 | | -- 🐛 Report a bug |
110 | | -- 💡 Suggest new features |
111 | | -- 🧪 Improve tests |
112 | | -- 📚 Enhance documentation |
113 | | -- 💻 Submit a PR |
| 119 | +## Requirements |
114 | 120 |
|
115 | | -We appreciate your help making PushForge better for everyone. |
| 121 | +- **Node.js 20+** or any runtime with Web Crypto API |
| 122 | +- Supported: Cloudflare Workers, Vercel Edge, Convex, Deno, Bun, modern browsers |
116 | 123 |
|
117 | | -## Reporting Issues |
| 124 | +## Development |
118 | 125 |
|
119 | | -Found a bug or have a feature request? Please [open an issue](https://github.com/draphy/pushforge/issues/new) and provide as much detail as possible. |
| 126 | +```bash |
| 127 | +git clone https://github.com/draphy/pushforge.git |
| 128 | +cd pushforge |
| 129 | +pnpm install |
| 130 | +pnpm build |
| 131 | +``` |
120 | 132 |
|
121 | | -## Sponsorship |
| 133 | +## Contributing |
122 | 134 |
|
123 | | -If you find PushForge valuable, consider [sponsoring the project](https://github.com/sponsors/draphy). Your sponsorship helps maintain and improve the library. |
| 135 | +Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. |
124 | 136 |
|
125 | 137 | ## License |
126 | 138 |
|
127 | | -This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
128 | | - |
129 | | ---- |
130 | | - |
131 | | -<div align="center"> |
132 | | - <sub>Built with ❤️ by <a href="https://github.com/draphy">David Raphi</a></sub> |
133 | | -</div> |
| 139 | +MIT © [David Raphi](https://github.com/draphy) |
0 commit comments