In this section
Resources / Developers / Embed
Host one service worker file so browsers ask for notification permission on your address instead of in a Hubbo window.
Hubbo can send a published post as a browser (web push) notification. A browser ties the notification permission to one origin. By default that origin is Hubbo’s: the bell in the widget opens a small window on app.hubbo.io, and nothing is installed on your site. If you want the browser to ask on your own address, and notifications to show your address, host one file. The product side is described in Push notifications.
hubbo-push-sw.js from that page (it is also at https://app.hubbo.io/hubbo-push-sw.js).https://your-site.com/hubbo-push-sw.js| Requirement | Why |
|---|---|
| Exactly this path, at the root | The embed registers /hubbo-push-sw.js. A file in a subfolder or under another name is not found. |
| Same origin as the page | Browsers do not register a service worker from another origin or from a CDN host. |
https (or localhost while developing) | Service workers and push need a secure context. |
A JavaScript content type, for example text/javascript | Browsers refuse a worker served as text/html or text/plain. |
| Status 200 without a redirect | A redirected worker script is refused. |
In frameworks, put the file in the folder that is served as-is: public/ in Next.js, Nuxt, Vite, Create React App and Astro, static/ in SvelteKit, and public/ or an assets entry in angular.json for Angular.
push and shows a notification with the post title, the start of its text and your icon.notificationclick and opens the post’s link, only when it is an http(s) address.fetch handler, caches nothing, stores nothing and loads no other script.It does not touch your pages
The embed registers the worker with the scope /hubbo-push/, a path your site does not use. A worker controls only pages inside its scope, so it never sees a request of your site and it does not replace or conflict with a service worker you already run at /.
/hubbo-push-sw.js. Registering asks the visitor nothing.Notification.requestPermission() and pushManager.subscribe() with Hubbo’s public VAPID key, then stores the subscription with client_savePushSubscription.client_removePushSubscription.If the registration fails (the file is missing, has the wrong content type, the page is not https, or your Content-Security-Policy blocks it), the bell opens the Hubbo window instead. The visitor sees no error. While the file is missing, each first opening of the panel requests /hubbo-push-sw.js once, so a 404 for that path in your logs means the file is not deployed on that origin.
If your site sends a Content-Security-Policy header, the worker needs worker-src 'self'. Without a worker-src directive browsers fall back to script-src (then default-src), which must include 'self'. The API calls go to https://api.hubbo.io, which the embed already needs in connect-src.
worker-src 'self';
script-src 'self' https://api.hubbo.io;
connect-src https://api.hubbo.io wss://api.hubbo.io;The Hubbo window is opened with window.open from the visitor’s click and needs no CSP entry. A sandbox policy without allow-popups blocks it.
https://your-site.com/hubbo-push-sw.js in a browser. You should see the script, not your 404 page./hubbo-push/ should be listed.The embed and the Hubbo window use these operations with the project key, like every client_* call. You do not need to call them yourself.
| Operation | Description |
|---|---|
client_getCurrentAccount | appearance.push is { enabled, ownDomain, publicKey } when visitors can subscribe, otherwise null. publicKey is Hubbo’s public VAPID key. |
client_savePushSubscription | Arguments subscription: JSON! (the result of PushSubscription.toJSON()) and language: String. Returns Boolean!. Only endpoints of known browser push services are accepted. Rate limited. |
client_removePushSubscription | Argument endpoint: String!. Returns Boolean!. Forgets the subscription with that endpoint. |
Signed-in users
A subscription is linked to the user your site identified with window.hubbo.identify(), so Logged in and trait targeting work for push. With Identity Verification on, the link needs a valid userHash; otherwise the browser is stored as an anonymous subscriber. See Identify visitors.
Switch back to In a Hubbo window and delete the file. Browsers that subscribed on your site keep their subscription until the visitor turns it off or clears site data; a subscription the browser dropped is removed from Hubbo at the next send.