๐Ÿ”” JavaScript

Browser Notifications โ€” Permission UX and the Notification API

๐Ÿ“… Jul 4, 2026 โฑ 2 min read

Notifications are powerful and universally abused. The API is easy; the UX discipline is the skill.

The API

// 1. check support + current state
if ("Notification" in window) {
  Notification.permission;   // "default" | "granted" | "denied"
}

// 2. request ONLY on user action (see UX rules)
const perm = await Notification.requestPermission();

// 3. show
if (perm === "granted") {
  new Notification("Streak saved! ๐Ÿ”ฅ", {
    body: "Day 12 of DSA practice complete.",
    icon: "/icon-192.png",
  });
}

The UX rules that decide everything

Local vs push

The above = local (page must be open). True push-when-closed needs a service worker + Push API + a server holding subscriptions โ€” a weekend project on top of the PWA basics. For a study-streak reminder feature, local notifications + a PWA cover a surprising amount.

โ† All Articles