Skip to main content
Sendrealm Web Push uses native browser Push API subscriptions and VAPID keys.

Requirements

  • A Sendrealm Push App with the Web provider active.
  • A React, Vite, or Next.js app served over HTTPS. Localhost works for development.
  • The Sendrealm service worker served from the same origin as your app.
  • A permission prompt triggered from a user gesture, such as clicking an Enable notifications button.

Activate The Web Provider

Open your Push App provider settings in the dashboard. The Web provider stores Sendrealm-managed VAPID keys. In most apps you do not need to copy these keys manually; the React SDK handles browser setup after initialization. If keys are missing, click Activate provider. Use Regenerate keys only when you intentionally want browsers to create fresh subscriptions.

Install The SDK

Copy the service worker:
The setup command detects your public directory and writes sendrealm-service-worker.js there. Re-run it after SDK upgrades. Manual copy is also supported:

Initialize React

Keep autoRequestPermission false unless your UX already guarantees initialization runs from a user action. Browsers can block permission prompts that are not user-initiated. init() is idempotent and safe under React StrictMode duplicate effects. The package also exports SendrealmProvider for advanced custom-client cases, but it is not required for normal React, Vite, or Next.js apps.

Add A Prompt Button

After opt-in, the browser is registered with Sendrealm and can be targeted from the dashboard or API.
You can then target web devices by device_ids, contact_ids, external_ids, emails, audiences, or platforms: ["web"] from the API.

Next.js Notes

Call init() from a Client Component and put the service worker file under public/.
Render <SendrealmInit /> once near your root layout or app shell.

Worker Hosting Notes

The browser must load the registered service worker from the same origin as your app. Do not register raw.githubusercontent.com, GitHub Pages, or a CDN URL directly as serviceWorkerPath. If you download the worker from GitHub Releases, still deploy the file into your app’s public directory and register it as /sendrealm-service-worker.js.

iOS Notes

iOS Web Push works only for installed Home Screen web apps. Your site must be HTTPS, provide a valid web app manifest, and ask for permission from a user gesture inside the installed PWA.

Full SDK Reference

See React Web Push SDK for hooks, diagnostics, launch URLs, image support, notification event listeners, and the complete client API.