Introduction to the Notification API
Understand what the Tauri Notification API is, how to install the required plugin, configure permissions, and send your first system notification.
A desktop or mobile application often needs to alert the user about events—a new message, a completed download, a meeting reminder. The Notification API gives your Tauri app the ability to display system-level notification toasts that appear even when the app is not in focus. This section covers what the plugin does, how to set it up, and the permissions you must grant before you can send anything.
What the Notification API Does
The Tauri Notification API is a bridge between your application code and the operating system’s native notification system. On macOS it talks to the Notification Center, on Windows to the Action Center, on Linux to the desktop notification daemon, and on mobile to the platform-specific notification frameworks. This means a notification sent from your Tauri app looks and behaves exactly like any other system notification—it respects Do Not Disturb settings, appears in the notification history, and can include sounds, actions, or attachments where the platform supports them.
The plugin is exposed to your frontend through JavaScript functions. You can check whether the user has granted notification permission, request that permission if needed, and then fire a notification with a title, body, icon, and other optional fields. The Rust side also has full access to the same capabilities, so you can trigger notifications from background tasks or system events without round-tripping through the webview.
Official Plugin:
This feature comes from the official tauri-plugin-notification crate and its companion npm package @tauri-apps/plugin-notification. It is not built into Tauri’s core, so you must add it explicitly. See Installing Plugins for the general plugin install pattern.
Plugin Installation
Setting up notifications requires changes on both the Rust backend and the JavaScript frontend. The steps below assume you already have a Tauri v2 project with a React + Vite frontend.
Step 1: Add the Rust crate dependency
Run this command in your project root (or inside src-tauri) to add the plugin to Cargo.toml:
cargo add tauri-plugin-notification
This pulls the latest version from crates.io and updates src-tauri/Cargo.toml.
Step 2: Register the plugin in Rust
Open src-tauri/src/lib.rs and initialise the plugin inside the builder chain:
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_notification::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
The .plugin(…) call must appear before .run(). If you have other plugins, the order does not matter.
Step 3: Install the JavaScript package
From your project’s root, install the npm package that exposes the notification functions to your React code:
npm install @tauri-apps/plugin-notification
You can also use yarn add or pnpm add—whatever your project uses.
Rust version check:
The plugin requires Rust version 1.77.2 or later. Run rustc --version to confirm.
Step 4: Grant permissions
Tauri’s security model demands that every plugin command be explicitly allowed. Create or edit a capability file (usually src-tauri/capabilities/default.json) and add "notification:default" to the permissions array:
{
"identifier": "default",
"description": "Capability for the main window",
"windows": ["main"],
"permissions": [
"core:default",
"notification:default"
]
}
This single permission string grants every notification-related operation—sending, cancelling, managing channels, and reading pending notifications.
Missing permissions will break notifications:
If you omit "notification:default", any call to sendNotification or isPermissionGranted will throw an error. There is no silent fallback; the notification simply won’t appear.
Basic Usage Example
Once the plugin is installed and permissions are configured, you can send a notification directly from a React component. The pattern is always the same: check permission, request if needed, then send.
Here is a small, self-contained NotificationSender component:
import { useState } from "react";
import {
isPermissionGranted,
requestPermission,
sendNotification,
} from "@tauri-apps/plugin-notification";
export default function NotificationSender() {
const [status, setStatus] = useState("");
async function handleSend() {
setStatus("Checking permission...");
let granted = await isPermissionGranted();
if (!granted) {
const perm = await requestPermission();
granted = perm === "granted";
}
if (!granted) {
setStatus("Permission denied.");
return;
}
sendNotification({
title: "Hello from Tauri",
body: "This is your first system notification!",
});
setStatus("Notification sent!");
}
return (
<div>
<button onClick={handleSend}>Send Notification</button>
<p>{status}</p>
</div>
);
}
The component imports three functions directly from the plugin package. When the user clicks the button, it first asks the operating system whether the app already has permission. If not, it calls requestPermission(), which triggers the system’s native permission dialog (on macOS, Windows, and mobile; on most Linux desktops permission is implicitly granted). Once the permission resolves to "granted", sendNotification fires a toast with a title and body.
After clicking, you should see a system notification pop up. On Windows, the notification appears in the Action Center. On macOS, it slides in from the top right. On Linux, the behaviour depends on your desktop environment.
Windows notifications require an installed app:
On Windows, notifications work only when the application is properly installed (for example, via an MSI installer). When running from a development server or a raw .exe moved outside the build folder, notifications may not appear. This is a known platform limitation, not a bug in the plugin.
Platform Considerations
The plugin aims for consistent behaviour across all supported platforms, but some differences exist:
| Platform | Notification system | Requires explicit permission? | Notes |
|---|---|---|---|
| Windows | Windows Action Center | Yes | Only works for installed applications. |
| macOS | Notification Center | Yes | Permission dialog appears on first call. |
| Linux | Desktop notifications (libnotify / notify-rust) | Usually no | Behaviour depends on the desktop environment. |
| Android | Android notification system | Yes | Channels are required for Android 8+. |
| iOS | User Notifications framework | Yes | Permission dialog appears on first call. |
These differences are handled by the plugin internally. As long as you follow the permission check and request flow, the same JavaScript code works everywhere.
Summary
If your immediate need is simply to fire a basic toast, the example above is all you need.