Skip to content

Commit 2945a29

Browse files
fix: [WPN-30] Clarify Convex requires 'use node' directive (#63)
1 parent aa7b711 commit 2945a29

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Traditional web push libraries like `web-push` rely on Node.js-specific APIs tha
3838
```
3939
❌ Cloudflare Workers - "crypto.createECDH is not a function"
4040
❌ Vercel Edge - "https.request is not available"
41-
❌ Convex - "Top-level await is not supported"
4241
```
4342

4443
## The Solution
@@ -67,10 +66,12 @@ await fetch(endpoint, { method: "POST", headers, body });
6766
| Dependencies | **0** | 5+ |
6867
| Cloudflare Workers || [](https://github.com/web-push-libs/web-push/issues/718) |
6968
| Vercel Edge |||
70-
| Convex |||
69+
| Convex |* ||
7170
| Deno / Bun || Limited |
7271
| TypeScript | Native | @types |
7372

73+
\* Requires `"use node";` directive — [see example](packages/builder#convex)
74+
7475
## Quick Start
7576

7677
```bash

packages/builder/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ Try PushForge in your browser at **[pushforge.draphy.org](https://pushforge.drap
4040
| Dependencies | **0** | 5+ (with nested deps) |
4141
| Cloudflare Workers | Yes | [No](https://github.com/web-push-libs/web-push/issues/718) |
4242
| Vercel Edge | Yes | No |
43-
| Convex | Yes | No |
43+
| Convex | Yes* | No |
4444
| Deno / Bun | Yes | Limited |
4545
| TypeScript | First-class | @types package |
4646

47+
\* Convex requires `"use node";` directive. [See example](#convex).
48+
4749
Traditional web push libraries rely on Node.js-specific APIs (`crypto.createECDH`, `https.request`) that don't work in modern edge runtimes. PushForge uses the standard [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API), making it portable across all JavaScript environments.
4850

4951
## Quick Start
@@ -232,7 +234,11 @@ export default async function handler(request: Request) {
232234

233235
### Convex
234236

237+
> **Note:** Convex's default runtime doesn't support ECDH operations required by Web Push. Add `"use node";` to use the Node.js runtime.
238+
235239
```typescript
240+
"use node";
241+
236242
import { action } from "./_generated/server";
237243
import { buildPushHTTPRequest } from "@pushforge/builder";
238244
import { v } from "convex/values";
@@ -327,7 +333,7 @@ self.addEventListener('notificationclick', (event) => {
327333
| Vercel Edge | Fully supported |
328334
| Deno | Fully supported |
329335
| Bun | Fully supported |
330-
| Convex | Fully supported |
336+
| Convex | Requires `"use node";` ([example](#convex)) |
331337
| Modern Browsers | Fully supported |
332338
333339
<details>

0 commit comments

Comments
 (0)