Skip to content

feat: web push notifications for custom domains#3001

Open
Soxasora wants to merge 3 commits into
stackernews:masterfrom
Soxasora:feat/custom-domains-webpush
Open

feat: web push notifications for custom domains#3001
Soxasora wants to merge 3 commits into
stackernews:masterfrom
Soxasora:feat/custom-domains-webpush

Conversation

@Soxasora

@Soxasora Soxasora commented Jun 5, 2026

Copy link
Copy Markdown
Member

Description

Push notifications on custom domains work out of the box, but they have a couple of issues:

  1. They’re essentially duplicating the Stacker News push notifications; this causes users of both SN and custom domain PWA to receive the same notifications twice.
  2. Notifications are Stacker News branded
  3. Clicking on a notification redirects to stacker.news because of the hardcoded notification.navigate URL

This PR handles (2) and (3), the first issue is instead something we need to explore in-depth.

Screenshots

Branded push subscription:

image

Navigation to custom domain:

push-navigation.mp4

Additional Context

Checklist

Are your changes backward compatible? Please answer below:

Yes, PushSubscription table now has the domainId foreign key to carry the domain context across web push.

On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:

6, push notifications for custom domains work great, and SN push notifications work as expected. Didn't test navigation on mobile devices.

Did you use AI for this? If so, how much did it assist you?

Yes, review


Note

Medium Risk
Changes user-visible push behavior (URLs and branding) for all subscriptions; schema migration is backward compatible but per-subscription payload logic is new surface area for regressions on main SN and custom domains.

Overview
Push subscriptions now record which host the user subscribed from via optional domainId on PushSubscription, resolved at save time through a new lazy getDomain() on GraphQL context (from req.headers.host).

Sending builds notification payloads per subscription: custom-domain favicon/title, absolute navigate URLs on the territory’s domain (not hardcoded NEXT_PUBLIC_URL), and a branded “notifications are now active” reply. getDomainMappingById supports lookup when only domainId is stored.

Existing rows keep domainId null and behave like main Stacker News. Duplicate notifications across SN and a custom-domain PWA are not addressed here.

Reviewed by Cursor Bugbot for commit 6121d55. Bugbot is set up for automated code reviews on this repo. Configure here.

@Soxasora Soxasora marked this pull request as ready for review June 5, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant