R
fn

useWebNotification

v0.0.15testeddemo

Reactive, SSR-safe wrapper around the Web Notification API with permission handling and `onClick`/`onShow`/`onError`/`onClose` event hooks.

Examples

ts
const { show, isSupported, onClick } = useWebNotification({
  title: 'Hello',
  body: 'You have a new message',
  icon: '/icon.png',
});
onClick(() => console.log('clicked'));
if (isSupported.value)
  show();
ts
// Override options per call
const { show } = useWebNotification();
show({ title: 'Override', body: 'Per-call body' });

Demo

Loading demo…

Signature

ts
export function useWebNotification(
  options: UseWebNotificationOptions ={ ... }

Parameters

ParameterTypeDescription
options?UseWebNotificationOptionsDefault notification options plus behavior flags

Returns

UseWebNotificationReturn`isSupported`, `notification`, `permissionGranted`, `show`, `close`, `ensurePermissionGranted`, and the `onClick`/`onShow`/`onError`/`onClose` hooks