use_web_notification
Reactive Notification API.
The Web Notification interface of the Notifications API is used to configure and display desktop notifications to the user.
Demo
Usage
use leptos::prelude::*;
use leptos_use::{use_web_notification_with_options, UseWebNotificationOptions, ShowOptions, UseWebNotificationReturn, NotificationDirection};
#[component]
fn Demo() -> impl IntoView {
let UseWebNotificationReturn {
show,
close,
..
} = use_web_notification_with_options(
UseWebNotificationOptions::default()
.direction(NotificationDirection::Auto)
.language("en")
.renotify(true)
.tag("test"),
);
show(ShowOptions::default().title("Hello World from leptos-use"));
view! { }
}
Server-Side Rendering
Make sure you follow the instructions in Server-Side Rendering.
This function is basically ignored on the server. You can safely call show but it will do nothing.
Feature
This function is only available if the crate feature
use_web_notificationis enabled
Types
enum NotificationDirectionstruct UseWebNotificationOptionsstruct ShowOptionsenum NotificationPermissionstruct UseWebNotificationReturn