Push Notifications
Web Push notifications allow Org Comms to re-engage members even when the application isn't open. Using Service Workers and VAPID keys, you can deliver real-time alerts to desktop and mobile devices.
How it works
VAPID Security
npx web-push generate-vapid-keys and add them to your Convex environment.Service Workers
public/sw.js runs in the background, listens for push events, and displays the notification — even when the main browser tab is closed.The delivery flow
From admin action to device notification — four steps handled entirely by Org Comms and Convex.
The Implementation Chain
User Permission
Modern browsers require a manual user gesture to request notification permissions. This is why Org Comms includes an 'Enable Alerts' button.
Subscription Creation
Once permitted, the browser generates a unique endpoint and cryptographic keys for that specific browser instance.
Secure Storage
Subscriptions are stored in Convex linked to the user account, enabling targeted broadcasts without managing complex infrastructure.
Broadcast Delivery
When an admin sends a message, an internal Node.js action in Convex triggers the web-push protocol to reach the user.
Optimising for Mobile (PWA)
For a native-like notification experience on iOS and Android, it is highly recommended to install the application as a PWA from the browser's "Add to Home Screen" option.
- Persistence: PWA apps maintain background sync more reliably than browser tabs.
- Badging: App icon badges can reflect the number of unread messages.
- Trust: Home screen apps usually have higher notification permission retention rates.
Setting up push notifications
Generate VAPID keys
Run npx web-push generate-vapid-keys to generate your public/private VAPID key pair.
Add keys to environment
Set VITE_VAPID_PUBLIC_KEY in .env.local and VAPID_PUBLIC_KEY + VAPID_PRIVATE_KEY in the Convex dashboard using npx convex env set.
Enable alerts in the app
After signing in, navigate to the Messages page and click 'Enable Alerts'. Grant notification permission in the browser prompt.
Send a test message
As an admin, send a broadcast message. The recipient should receive a browser/device notification within seconds.