Skip to main content
requestNotificationPermission() already picks the right path: the device token in a shell, a Web Push subscription in a browser. useWebPush is for the UI around that subscription: an on/off switch that reflects the real state, and the iOS install instructions.

Status

boolean
Whether subscribing is possible here.
boolean
Whether this browser holds a subscription for your app.
'default' | 'granted' | 'denied' | 'unsupported'
The browser’s notification permission.
boolean
iOS in a tab: the app must be added to the Home Screen first. Show instructions rather than a button.
string
Why it is unavailable: native (running in a shell), unsupported (no Push API), needs-install (iOS, not installed), not-configured (no push key on this deployment), denied (the user refused).

Things to know

  • Subscriptions are per origin. photos.cskn.app and feed.cskn.app need separate permission and separate subscriptions; one cannot push for the other.
  • Call subscribe() from a click. Browsers do not show the prompt otherwise, and Chrome may remember the refusal permanently.
  • You ship no service worker or manifest. The platform serves both on your app’s origin (/cskn-sw.js, /manifest.webmanifest). If your app ships its own manifest, it is left alone.
  • useWebPush registers the service worker on mount. That is also what makes the app installable and adds an offline fallback. Pass { register: false } to skip it.
The hook also returns refresh(), plus standalone (running as an installed app) and ios. Functions: getWebPushStatus, subscribeWebPush, unsubscribeWebPush, registerServiceWorker, isStandalone, isIos.