js!

The js! macro embeds raw JavaScript for cases where rs2js translation is insufficient.

Basic usage

let count = use_signal(0);

view! {
    <button onClick={ js! {
        state.count.update(c => c + 1);
    }}>
        "+"
    </button>
}

Server actions

view! {
    <button onClick={ js! {
        const result = await __resuma.action('greet', ['World']);
        state.message.set(result);
    }}>
        "Greet"
    </button>
}

When to use js!

  • Async fetch patterns with await __resuma.action(...)
  • Browser APIs not expressible in Rust closures
  • Complex client-side orchestration

Prefer rs2js when possible

Plain Rust closures in onClick are translated automatically and stay type-checked on the server side. Reach for js! only when you need full JS syntax.