leptos_use

Function use_window

Source
pub fn use_window() -> UseWindow
Expand description

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

let window = use_window();

// Returns `None` on the server but will not panic.
let navigator = window.navigator();