Skip to content
Tauri

Notifications

Send native notifications to your user using the notification plugin.

Setup

Install the notifications plugin to get started.

Use your project’s package manager to add the dependency:

npm run tauri add notification

Usage

Here are a few examples of how to use the notification plugin:

The notification plugin is available in both JavaScript and Rust.

Send Notification

Follow these steps to send a notification:

  1. Check if permission is granted

  2. Request permission if not granted

  3. Send the notification

import {
isPermissionGranted,
requestPermission,
sendNotification,
} from '@tauri-apps/plugin-notification';
// Do you have permission to send a notification?
let permissionGranted = await isPermissionGranted();
// If not we need to request it
if (!permissionGranted) {
const permission = await requestPermission();
permissionGranted = permission === 'granted';
}
// Once permission has been granted we can send the notification
if (permissionGranted) {
sendNotification({ title: 'Tauri', body: 'Tauri is awesome!' });
}

Actions

Attachments

Channels

Security Considerations

Aside from normal sanitization procedures of user input there are currently no known security considerations.


© 2024 Tauri Contributors. CC-BY / MIT