Svelte 5 SDK for Deep Agents, LangChain and LangGraph.
useStream binds a LangGraph agent into a Svelte 5 component. Reactive fields are exposed as getters on a stable handle (stream.messages, stream.isLoading, …) so templates and $derived expressions track updates automatically — no stores, no $ prefix, no destructuring.
npm install @langchain/svelte @langchain/core
Peer dependencies: svelte ^5.0.0, @langchain/core ^1.0.1
<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
disabled={stream.isLoading}
onclick={() =>
stream.submit({ messages: [{ type: "human", content: "Hello!" }] })}
>
Send
</button>
Note: Access fields through the live
streamhandle. Destructuring (const { messages } = stream) freezes the values at that moment — usestream.messagesin templates instead.
reconnectOnMount / joinStream dance.values, messages, toolCalls, and interrupts are reactive at the root with zero extra subscription cost.threadId. Pass threadId: () => active to drive in-place thread swaps without remounting.useStream<typeof agent>() unwraps state, tool calls, and subagent state maps from an agent brand.In-depth guides live in docs/:
useStream — options, return shape, reactive threadIduseMessages, useToolCalls, useValues, …)respond(), stop(), hydrationPromiseprovideStream / getStream)AgentServerAdapter, HttpAgentServerAdapter)@langchain/svelte v1 targets the v2 streaming protocol. The useStream import stays the same, but the option bag, return shape, and how you subscribe to scoped data all change. Most chat apps migrate in well under an hour — the full guide with line-by-line diffs lives in docs/v1-migration.md.
For full end-to-end examples, see the LangChain UI Playground.
MIT
Strip headless-tool interrupts from a user-facing interrupt list.
Execute and resume all newly seen headless-tool interrupts from a values
Reads the shared stream handle exposed by the nearest ancestor
Parses a headless-tool interrupt value from the graph. Accepts both
Creates a shared useStream handle and publishes it via
Subscribe to a scoped audio-media stream. Each handle is yielded
Progressive audio playback for AudioMedia handles with a
Side-effect counterpart to useChannel. Instead of returning a
Subscribe to a custom:<name> stream extension — the most-recent
Subscribe to a scoped file-media stream. Pair with useMediaURL
Subscribe to a scoped image-media stream. Pair with useMediaURL
Resolve the lazy MediaBase.objectURL promise into a
Read metadata recorded for a specific message id — today exposes
Subscribe to a scoped messages stream.
Svelte binding over ChannelRegistry.acquire. Mirrors the
Svelte 5 binding for the v2-native stream runtime.
Subscribe to a scoped tools (tool-call) stream. Same target and
Subscribe to a scoped values stream — the most recent state
Subscribe to a scoped video-media stream. Pair with useMediaURL
Bind a VideoMedia handle to a caller-owned <video>