Macro leptos_dom::is_server
source · macro_rules! is_server {
() => { ... };
}
Expand description
Shorthand to test for whether an ssr
feature is enabled.
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
};