* Change the suspense streaming context after suspense is resolved in the router * Wait for the suspense context before streaming the first chunk in ssr * forward more response parts * warn * extract the hydration format into a crate * Fix hydration when no data is sent * forward web and server features * Fix suspense that starts on the client * fix use_server_future on the client * Add documentation for fullstack hooks and protocol * downgrade rust edition * fix clippy * fix tests * fix clippy * Fix pure web compile * undo changes to the fullstack router example * fix formatting
33 lines
1.0 KiB
Markdown
33 lines
1.0 KiB
Markdown
# Dioxus Fullstack Hooks
|
|
|
|
Dioxus fullstack hooks provides hooks and contexts for [`dioxus-fullstack`](https://crates.io/crates/dioxus-fullstack). Libraries that need to integrate with dioxus-fullstack should rely on this crate instead of the renderer for quicker build times.
|
|
|
|
## Usage
|
|
|
|
To start using this crate, you can run the following command:
|
|
|
|
```bash
|
|
cargo add dioxus-fullstack-hooks
|
|
```
|
|
|
|
Then you can use hooks like `use_server_future` in your components:
|
|
|
|
```rust
|
|
use dioxus::prelude::*;
|
|
async fn fetch_article(id: u32) -> String {
|
|
format!("Article {}", id)
|
|
}
|
|
|
|
fn App() -> Element {
|
|
let mut article_id = use_signal(|| 0);
|
|
// `use_server_future` will spawn a task that runs on the server and serializes the result to send to the client.
|
|
// The future will rerun any time the
|
|
// Since we bubble up the suspense with `?`, the server will wait for the future to resolve before rendering
|
|
let article = use_server_future(move || fetch_article(article_id()))?;
|
|
|
|
rsx! {
|
|
"{article().unwrap()}"
|
|
}
|
|
}
|
|
```
|