Svelte 5 binding for the v2-native stream runtime.
Returns a handle whose reactive fields are plain getters on a
stable object ā templates can read stream.messages directly and
$derived(stream.isLoading) auto-tracks the getter.
| Name | Type | Description |
|---|---|---|
options* | UseStreamOptions<InferStateType<T>> |
<script lang="ts">
import { useStream } from "@langchain/svelte";
const stream = useStream({
assistantId: "agent",
apiUrl: "http://localhost:2024",
});
</script>
{#each stream.messages as msg (msg.id)}
<div>{msg.content}</div>
{/each}
<button onclick={() =>
stream.submit({ messages: [{ type: "human", content: "Hi" }] })
}>
Send
</button>