Tasks

Tasks run side effects on the server during render, or register client-only work for after visibility.

LIVE

visible_task!

This panel uses visible_task! — the message below appears when the demo scrolls into view.

Waiting for viewport…

use_task

Alias for use_effect — runs during SSR and re-runs when tracked signals change.

let filter = signal("all".into());

use_task(move || {
    let f = filter.get();
    // Sync derived state, logging, etc.
    println!("filter: {f}");
});

use_visible_task

Registers a client-only task in the resumability payload. The runtime executes the JS body after the component becomes visible. When the body uses state.my_signal, pass each signal to visible_task! so the client wires captures.

let armed = signal(false);

visible_task!(
    r#"
    async (state, __resuma) => {
        state.armed.set(true);
    }
"#,
    armed
);

use_debounce

Debounce signal-driven callbacks — see the Debouncer cookbook for a full search example.

let query = signal(String::new());

use_debounce(&query, 300, move |q| {
    if !q.is_empty() {
        println!("search: {q}");
    }
});

Choosing a hook

  • use_task — server-safe effects tied to signals
  • use_visible_task — browser-only initialization (analytics, charts)
  • use_debounce — rate-limit expensive reactions to input