Introduction
Lerix delivers web push using the standard Web Push protocol (VAPID) — the same open standard Chrome, Firefox, Edge, and modern Safari all implement natively. No Firebase project, no OneSignal account — Lerix generates and manages the key pair for you.This is a separate package from the Flutter SDK —
@lerix-dev/lerix-js
is a small, framework-agnostic JS/TS library for non-Flutter web apps
(React, Vue, plain HTML, etc.). If your app is built with Flutter —
including Flutter Web — don’t use this package; the lerix Flutter
package supports iOS, Android, and Web natively from one package with one
API. See Flutter — Push Notifications
instead.1. Install
2. Copy the service worker
Web Push requires a service worker file served from your site’s own origin — a plain<script> import can’t register one for you. Copy
node_modules/@lerix-dev/lerix-js/sw/lerix-sw.js to your site’s public
root so it’s reachable at https://yoursite.com/lerix-sw.js (any path
works, as long as you pass it to subscribe() if it’s not at that default).
3. Generate a Web Push key
From the dashboard: Notifications → Settings → Web Push → Generate keys. This is a one-click step — Lerix generates and stores the VAPID key pair for the project; there’s nothing to copy into your code.4. Use it
API
The notification payload
Both callbacks receive anLerixNotificationPayload — the same shape the
Flutter SDK’s model uses:
Sending an image
SetimageUrl when sending — from the dashboard’s Send notification
tab, or the REST API’s imageUrl parameter.
Unlike iOS, this works automatically on the web with no extra setup: the
service worker renders it directly as the notification’s icon/image.
Sending metadata
Setmetadata when sending — delivered back to the page inside
payload.metadata, for routing a tap to a specific in-app view, for example.
See Sending metadata
for the full parameter details (identical across every platform).
Custom sound is not supported for web push. The Web Notifications API
doesn’t expose a way to set a custom notification sound across browsers,
so the dashboard/API’s
sound parameter is ignored for web recipients —
it only applies to iOS and Android.Target a user on every device
If your product also ships on other platforms (web, mobile or desktop), add them to the same project and link each install to your own user ID after login. Your backend can then send toexternalUserIds and reach that person
on every device in one request.
Browser support
Chrome, Firefox, and Edge support Web Push fully. Safari requires macOS 13+ or iOS 16.4+ — older Safari doesn’t support the standard at all.Flutter Web
Don’t use this JS SDK for a Flutter app, even a Flutter Web build — thelerix Flutter package supports iOS, Android, and Web natively from a
single package, calling the browser’s Push API directly with no separate JS
dependency at all. Same Lerix.notifications.* calls, same
LerixNotificationPayload shape, on every platform: