use_window
SSR safe window().
This returns just a new-type wrapper around Option<Window>.
Calling this amounts to None on the server and Some(Window) on the client.
It provides some convenient methods for working with the window like document() and navigator().
These will all return None on the server.
Usage
use leptos::prelude::*;
use leptos_use::use_window;
#[component]
fn Demo() -> impl IntoView {
let window = use_window();
// Returns `None` on the server but will not panic.
let navigator = window.navigator();
view! { }
}
Feature
This function is only available if the crate feature
use_windowis enabled