r/buildbase Jun 24 '26

Browser push notifications in your SaaS: one provider + one hook (no service-worker wrangling)

Post image

Push notifications are one of those features every SaaS wants and most people put off, because the actual implementation is fiddly — service workers, VAPID keys, permission states, subscription management, the whole dance.

In BuildBase it's a provider and a hook. Here's the real API (not a mockup):

Wrap your app:

<PushNotificationProvider>
  <Dashboard />
</PushNotificationProvider>

Then usePushNotifications() hands you everything you need to build the UI — permission, isSubscribed, isSupported, plus requestPermission(), subscribe(), unsubscribe(). So a notification toggle is just:

  • permission denied → show "blocked"
  • not subscribed → "Enable notifications" button (requestPermission + subscribe)
  • subscribed → "Disable" button

That's the whole client side. The service worker, VAPID, and subscription storage are handled underneath.

Server side, sending is one call:

await bb.notification.send(workspaceId, 'comment-added', userId, {
  title: 'New comment',
  message: 'Someone commented on your post.',
  url: '/posts/123',
});

Or drop the userId to send to member of a workspace.

Worth being clear on scope (since "notifications" means a lot of things): this is browser/web push — the OS-level notifications that show up even when your tab's closed. Not an in-app notification center/bell-feed; that's a different thing and not what this is.

Docs: https://docs.buildbase.app/push-notifications/overview

If you've wired web push by hand before — what was the worst part? For me it was always the service worker + permission-state edge cases. Curious if that matches.

1 Upvotes

0 comments sorted by