Overview
The framework-agnostic core. A single PWAManager class covering service-worker registration, the Notification permission, and the PushSubscription lifecycle.
@jopgood/pwa-core is one class, PWAManager, composing three concerns over a shared reactive store.
What it does
- Service-worker registration with lifecycle tracking (
installing→waiting→active) and a "skip waiting" trigger for activating updates. - Notification permission - reads the current state, requests it on demand, mirrors it into the store.
- Push subscription - subscribes against your VAPID key, fires a callback when the subscription changes so you can send it to your backend, supports unsubscribe.
All three write into a single @tanstack/store instance exposed as manager.store. Framework adapters subscribe to that store; direct subscriptions work too.
What it doesn't do
- Routing, UI, or banners. No components are included.
- Caching strategies. Those belong in the
sw.jsfile. Caching strategies on MDN ↗ - Sending push messages. You'll need to run a push server (typically
web-push) and POST the subscription to it fromonSubscriptionChange.
When to use the core directly
- The project isn't using React (vanilla JS, Web Components, a Chrome extension).
- A single source of truth is needed across multiple framework islands.
- A custom framework adapter is being built.
For React, the adapter wires the manager into context.
Where next
Tutorial
Quick start
Subscribe a user to push notifications in under a minute.
Reference
API reference
Complete surface of PWAManager and the store.