sycamore::web

Function render_to_string_await_suspense

pub async fn render_to_string_await_suspense(
    view: impl FnOnce() -> View,
) -> String
Expand description

Renders a View into a static String while awaiting for all suspense boundaries to resolve. Useful for rendering to a string on the server side.

This sets the SSR mode to “blocking” mode. This means that rendering will wait until suspense is resolved before returning.

§Example

#[component]
async fn AsyncComponent() -> View {
    // Do some async operations.   
}

let ssr = render_to_string_await_suspense(AsyncComponent).await;