Function use_server_cached

Source
pub fn use_server_cached<O: 'static + Clone + Serialize + DeserializeOwned>(
    server_fn: impl Fn() -> O,
) -> O
Expand description

This allows you to send data from the server to the client. The data is serialized into the HTML on the server and hydrated on the client.

When you run this function on the client, you need to be careful to insure the order you run it initially is the same order you run it on the server.

If Dioxus fullstack cannot find the data on the client, it will run the closure again to get the data.

ยงExample

use dioxus_lib::prelude::*;
use dioxus_fullstack::prelude::*;

fn app() -> Element {
   let state1 = use_server_cached(|| {
      1234
   });

   unimplemented!()
}