KScript docs
EN

Components

Stream an action's output

Paste this block into index.html and click Run. The action sends text to the element named progress. In a longer action, each chunk can appear before the action finishes.

HTML page
<live id="stream-demo">
  <p live-stream="progress" role="status"></p>
  <button on-click="@stream('progress', 'Ready'); @skip_render()">Run</button>
</live>

Call @stream() more than once to send several chunks. The target must be rendered in the same component. Chunks append by default. Use mode: replace for a progress label, and html: true only with markup you trust. A successful action normally replaces the preview with its final rendered fragment. Use @skip_render() to keep the streamed output. A failed action restores the pre-stream content. Actions that change session cookies, such as signing in or out, need a regular response.