Skip to main content

Introduction

Lerix delivers push notifications to React apps 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. After you complete the React installation, follow the steps below to enable push delivery.
Make sure your app is wrapped in LerixProvider before configuring push notifications.

1. Copy the service worker

Web Push requires a service worker file served from your app’s own origin — a package can’t add this file to your app automatically. Copy it into your public folder so it’s reachable at your site’s root:

2. 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.

3. Subscribe

subscribe() prompts for notification permission, registers the service worker, subscribes this browser to push, and registers the subscription with the backend — one call for the whole flow.

The notification payload

Both callbacks receive a LerixNotificationPayload:

Device identifiers

All three return null until subscribe() has completed at least once.

Sending metadata

Attach arbitrary custom data with metadata (a JSON object) when sending — from the dashboard’s Send notification tab, or the REST API’s metadata parameter. It’s delivered back to the page inside payload.metadata:

Sending an image

Set imageUrl when sending — from the dashboard’s Send notification tab, or the REST API’s imageUrl parameter. This works automatically with no extra setup: the service worker renders it directly as the notification’s icon/image.
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 browser 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 to externalUserIds and reach that person on every device in one request.
See Identify users for identity verification and a sending example.

Topics

Instead of targeting specific device tokens, a device can subscribe to a named topic — send one notification to the topic and every subscriber receives it. A topic doesn’t need to be created ahead of time; it’s created automatically the first time any device subscribes to it. You can also view, create, and delete topics from the Notifications → Topics tab in the dashboard.
To send to a topic, use the dashboard’s Send notification tab (select “Topic” as the audience), or call the REST API with sendByTopic: true.

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.