The notify() API allows for specialized behavior depending on the operating system:
macOS
Supports subtitles, interactive action buttons, inline replies, and custom sounds.
await notify({
title: "New Message",
subtitle: "John Doe",
body: "Hey, are you free for lunch?",
hasReply: true,
replyPlaceholder: "Type your reply...",
actions: [
{ type: "button", text: "Reply" },
{ type: "button", text: "Ignore" }
]
})
Windows
Supports custom layouts via toastXml and persistent notifications using timeoutType: "never".
await notify({
title: "Reminder",
body: "Meeting in 5 minutes",
timeoutType: "never"
})
Linux
Supports priority hints via the urgency property.
await notify({
title: "System Alert",
body: "Critical update available",
urgency: "critical"
})
// macOS with subtitle and actions
await notify({
title: "New Message",
subtitle: "John Doe",
body: "Hey, are you free for lunch?",
hasReply: true,
replyPlaceholder: "Type your reply...",
actions: [
{ type: "button", text: "Reply" },
{ type: "button", text: "Ignore" }
]
})
// Windows with custom timeout
await notify({
title: "Reminder",
body: "Meeting in 5 minutes",
timeoutType: "never"
})
// Linux with urgency
await notify({
title: "System Alert",
body: "Critical update available",
urgency: "critical"
})