Overview
A React adapter for @jopgood/pwa-core. One provider, three hooks, no extra state.
@jopgood/react-pwa exposes the core's store through React context. Everything available here can also be done with the core directly.
Exports
<PushProvider>- wires aPWAManagerinto context and callsmount()/unmount()for you.usePushNotifications()- full state and all actions in one hook.usePermission()- permission state and a request trigger.useSWUpdate()-swUpdateAvailableflag and anactivateWaitingtrigger.usePWAManager()- escape hatch to grab the manager from context.
Not included
- A pre-built subscribe button. You'll build the UI yourself.
- Caching strategies. Those live in the
sw.jsfile. Caching strategies on MDN ↗ - An install banner. The core doesn't capture
beforeinstallprompt.
How it's wired
Construct the PWAManager outside React and pass it to the provider. The hooks read from manager.store via @tanstack/react-store, so there's no parallel React state to keep in sync.
Peer dependencies
| Package | Version |
|---|---|
react | ≥ 18 |
react-dom | ≥ 18 |
@jopgood/pwa-core | workspace match |