Notifications
Hotaru can put the number of unread items on the installed app’s icon, and send push notifications for new items, also when the app is closed (SI-583). Both are off until you turn them on, under Settings → Notifications. Code: packages/core/src/notifications/, the page in settings/notifications, the service worker in service-worker/index.ts.
How it works
The server already fetches feeds by itself (scheduler.md), whether or not a browser is open. What tells your devices is Web Push: the server sends a push to each device’s push service (Google’s, Mozilla’s, Apple’s, Microsoft’s), and the app’s service worker shows the notification and sets the badge, even when no Hotaru tab is open. Periodic background sync isn’t used: only Chromium has it, and it runs when the browser likes.
- A new item is stored and goes through the AI pipeline (pipeline.md): the gate judges it and scores its Signal (scores.md). The push waits for that, so a minimum Signal can apply. Without a pipeline (
PIPELINE_ENABLED=false), items count when they arrive. - The items of the next 90 seconds are collected per user, then go out as one notification: “5 new items from 3 sources”. One new item names itself and its source.
- Each of your devices gets the push. A device whose subscription is over (the push service answers 404 or 410: the browser unsubscribed, the app was removed) is removed at once.
Which items notify: unread items your stream shows, so nothing the gate filtered out, a filter muted, a rule marked read, from a paused source, or that is part of a story whose lead you already have (dedupe.md). Also not:
- items published more than a day ago, such as a new source’s archive or an OPML import;
- the items of a source’s first fetch, in its first ten minutes;
- an item that already notified: each item counts once, also when it runs through the pipeline again.
Tapping a notification opens the item, or the stream for a group. An open Hotaru window is used; otherwise one opens. A new push while the last notification is still on screen joins it (“8 new items from 4 sources”) and alerts again, instead of piling up.
Settings
| Setting | For | What it does |
|---|---|---|
| Push notifications on this device | This device | Asks the browser for permission (the first time), subscribes it and lists it under Devices. Off removes it. |
| Send a test notification | Your devices | Sends “Notifications work” to every device, and says what each push service answered: “Sent to 2 of 3 devices. Safari on iPhone: HTTP 403 BadJwtToken”. When this device shows it, the page says so too. |
| Devices | Your account | Every device that gets your pushes, with when it was added and last notified. Removing one turns push off there. |
| Only for chosen sources | Your account | Push only for sources marked Notify me. |
| Minimum Signal | Your account | Any, 25, 50 or 75 and up. Items without scores (too little text, or no AI) don’t notify with a minimum, as in the stream’s bounds. |
| Unread count on the app icon | Your account | The badge: the unread count of your stream, without its filters. It updates while Hotaru is open (on load, when it comes back into view, after reading, when new items arrive) and with each push. Off clears it. |
Notify me is on each source: the bell on its row in Sources, and the toggle in its editor (sources.md). It matters only while Only for chosen sources is on.
Signing out removes the browser’s device, so the next person to sign in there doesn’t get your notifications. When a session runs out and someone else signs in, the device goes too.
Where it works
| Platform | Push | Badge |
|---|---|---|
| Chrome, Edge (desktop, Android) | In the browser and the installed app | In the installed app |
| Firefox (desktop, Android) | In the browser | No |
| Safari on macOS | In Safari 16 or later on macOS 13 or later, and in the web app added to the Dock (macOS 14 Sonoma or later) | In the web app in the Dock |
| iPhone and iPad, iOS and iPadOS 16.4 or later | Only for Hotaru added to the Home Screen | On the Home Screen icon, once notifications are allowed |
What the page shows when push can’t work here, instead of a switch that does nothing:
- iPhone or iPad in a browser tab: add Hotaru to the Home Screen (Share → Add to Home Screen), open it from there and turn push on.
- Blocked: you said no once; allow notifications in the site’s settings (or the system settings for an installed app), then reload.
- Not https: browsers allow push only on secure addresses (and
localhost). - No Web Push: an old browser, or one without it.
Without badge support the badge setting still saves (it applies to your other devices), and the page says so.
Every push shows a notification: there is no badge-only push. Browsers treat a silent push as abuse, and Safari ends the subscription after a few. The badge changes with notifications, or while the app is open.
Self-hosting
It works without setup. On first use, the server makes its own VAPID key pair, the key the push services check every push against, and keeps it in the database (instance_settings, the private key encrypted with BETTER_AUTH_SECRET, like other stored secrets). Optional variables (deployment.md):
| Variable | Default | What it does |
|---|---|---|
VAPID_PUBLIC_KEY, VAPID_PRIVATE_KEY |
unset | Your own key pair, both base64url, instead of the stored one. Make one with npx web-push generate-vapid-keys. Both or neither. |
VAPID_SUBJECT |
the ORIGIN (then BETTER_AUTH_URL) when it’s an https address, else the project’s GitHub page |
Who runs the server, for the push services: mailto:you@your-domain or your https address. Apple answers 403 BadJwtToken for anything else (a localhost or .invalid address, a bare email without mailto:), so the server ignores such a value, logs a warning, and uses the default. FCM takes anything, which hides the problem until an Apple device subscribes. |
PUSH_BATCH_WINDOW_SECONDS |
90 |
How long new items are collected into one notification, 1–3600. |
Changing the key (setting the variables, removing them, or a new BETTER_AUTH_SECRET, after which the stored key can’t be read and a new one is made) ends every subscription: the push services refuse the new key for them. Each device subscribes again the next time Settings → Notifications is opened on it, or after turning push off and on.
The server sends pushes only to https addresses and never to private ones, since the address comes from the browser. PUSH_TEST_ENDPOINT_ORIGIN lets one local http origin through for the e2e tests’ fake push service. Never set it in production.
Troubleshooting
What the test says. “Sent to N devices” means each device’s push service answered 2xx: it took the push and delivers it when the device is online. Last notified in the device list is set by exactly that answer. A device whose push service refused is named with the service’s answer, such as HTTP 403 BadJwtToken (Apple doesn’t accept the VAPID subject: see VAPID_SUBJECT above) or HTTP 401/403 from FCM (the key changed: turn push off and on on the device).
Accepted, but nothing shows. The push reached the browser; what’s left is on the device:
- Focus and Do Not Disturb hide banners on the Mac, and a Focus shared across devices hides them on the iPhone too. The notifications still land in Notification Center.
- The system’s notification setting for the browser or app: on the Mac, System Settings → Notifications → Google Chrome, Safari, or the web app in the Dock; on the iPhone, Settings → Notifications → Hotaru.
- After a test, the settings page says “This device showed it” when its service worker showed the notification. Then the system hid the banner.
Accepted everywhere, shown nowhere, after a deploy. The browsers likely still run an old service worker without the push handler, because a CDN in front of the server serves a cached /service-worker.js. Check with curl -sI https://hotaru.example.com/service-worker.js: cf-cache-status: HIT or an age header means a cache answered. Bypass the cache for that path and /_app/version.json, and purge it (deployment.md). Devices pick up the new worker the next time the app opens or comes back into view; their subscriptions keep working.
Check the service worker by hand. In Chrome or Edge: DevTools → Application → Service workers. The worker should be “activated and running”, with none waiting to activate. Paste this into the Push field and press Push:
{"kind":"test","count":0,"items":[],"sources":[],"sourceTitle":null,"url":"/"}A “Notifications work” notification should appear. In the console, await (await navigator.serviceWorker.ready).getNotifications() lists what the worker shows right now. In Safari: Develop → Service Workers → the site, and the same line in its console.
Brave. Turning push on fails with “Registration failed - push service error” until push messaging is allowed: open brave://settings/privacy, turn on Use Google services for push messaging, restart Brave and turn push on again. The settings page says so when it sees that error.
Server log. Every test logs one line per device, with the push service’s host and answer, never the device’s address or the payload:
[push] test push to device 4654f273-… (web.push.apple.com): HTTP 201[push] test push to device 9c1e… (fcm.googleapis.com): HTTP 403 …; failedNew-item pushes log only failures and removed devices.
API
| Request | |
|---|---|
GET /api/v1/me/notifications |
{ badge, onlyChosenSources, minSignal, vapidPublicKey }. |
PATCH /api/v1/me/notifications { badge?, onlyChosenSources?, minSignal? } |
Changes what is sent. minSignal 0–1; null or 0 means any. Write token. |
GET /api/v1/me/notifications/devices |
{ devices: [{ id, label, createdAt, lastUsedAt }] }, newest first. Push addresses and keys never leave the server. |
POST /api/v1/me/notifications/devices { endpoint, keys: { p256dh, auth }, label? } |
Registers a browser’s push subscription (its toJSON()), made with vapidPublicKey. The same endpoint again updates its device, also for another account. 201; 422 for an address that isn’t https. Write token. |
DELETE /api/v1/me/notifications/devices/:id |
Stops pushes to a device. 204. Write token. |
POST /api/v1/me/notifications/test { deviceId? } |
A test notification to every device, or one: { sent, removed, failed, results }, with results one { deviceId, label, status, httpStatus, reason } per device (status is sent, gone or failed; reason is the push service’s, such as BadJwtToken). 404 without a device. Write token; counts as an expensive call (api.md). |
A source’s Notify me is notify on subscriptions: PATCH /api/v1/subscriptions/:id { notify }.
The SDK has notificationSettings(), updateNotificationSettings(), pushDevices(), registerPushDevice(), removePushDevice() and testPush(). A client without a browser can register only a subscription a browser made: the keys come from the browser’s push service.
What a push carries
The payload is JSON, encrypted for the device (aes128gcm, RFC 8291), at most a few hundred bytes: kind (items or test), count, up to three items (id, title), the source ids, the source’s name when there is only one, the url to open, and badge (the unread count) when the badge is on. The service worker writes the text. Pushes keep for a day while a device is offline, and a newer one replaces an older one that wasn’t delivered (Topic: hotaru-items).
Not yet
- Quiet hours, and a daily digest instead of pushes.
- A notification per followed story (stories.md).