Function leptos_dom::is_server

source ·
pub const fn is_server() -> bool
Expand description

Returns true if running on the server (SSR).

In the past, this was implemented by checking whether not(target_arch = "wasm32"). Now that some cloud platforms are moving to run Wasm on the edge, we really can’t guarantee that compiling to Wasm means browser APIs are available, or that not compiling to Wasm means we’re running on the server.

let todos = if is_server() {
    // if on the server, load from DB
} else {
    // if on the browser, do something else
};