Skip to main content

client

Attribute Macro client 

Source
#[client]
Expand description

Mark a component as an interactive island.

The component is rendered on the server as usual and wrapped in <nr-island data-component=".." data-props="..">. Its arguments are serialized (they must implement serde::Serialize) and become the island’s initial client state.

Without module, the island uses the built-in declarative runtime (data-nr-text, data-nr-on-click="increment:count", …). With #[client(module = "/_next-rust/client/islands/chart.js")] the runtime imports that ES module (for example wasm-bindgen output) and calls its hydrate(element, props) export.

Expansion (simplified):

ⓘ
pub fn Counter(count: i32) -> ::next_rust::Node {
    let props = /* {"count": count} as JSON */;
    fn inner(count: i32) -> impl View { /* original body */ }
    ::next_rust::__private::island("Counter", None, props, inner(count))
}