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
sendrealm-service-worker.js there. Re-run it after SDK upgrades. Manual copy is
also supported:
Initialize React
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
Link Signed-In Users
device_ids, contact_ids, external_ids, emails, audiences, or platforms: ["web"] from the API.
Next.js Notes
Callinit() from a Client Component and put the service worker file under public/.
<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 registerraw.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.