agentskit.js

@agentskit/svelte — for agents

Svelte 5 binding — `createChatStore` produces a Readable that drives any Svelte component.

#Purpose

Svelte binding for the ChatReturn contract from @agentskit/core. Returns a Readable<ChatState> plus action methods (send / stop / clear) and destroy() for cleanup.

#Install

npm install @agentskit/svelte
# peer:
npm install svelte

#Primary exports

  • createChatStore(config): SvelteChatStoreReadable<ChatState> + action methods + destroy().
  • Headless components (Svelte 5, mirroring @agentskit/react, data-ak-* only): ChatContainer, Message, InputBar, Markdown, CodeBlock, ToolCallView, ThinkingIndicator, ToolConfirmation.

#Minimal example

<script lang="ts">
import { createChatStore } from '@agentskit/svelte'
const chat = createChatStore({ adapter })
</script>

{#each $chat.messages as m (m.id)}
  <p>{m.content}</p>
{/each}
<form on:submit|preventDefault={() => chat.send($chat.input)}>
  <input bind:value={$chat.input} />
</form>

#Common patterns

  • Runes vs stores: works in both Svelte 5 runes mode and Svelte 4 stores — auto-subscription via $chat works the same.
  • Cleanup: call chat.destroy() in onDestroy() to abort in-flight streams and release the adapter.
  • SvelteKit SSR: packaged components render on the server. Start browser-bound adapters in onMount, or proxy provider calls through a server endpoint.

#Source

Explore nearby

✎ Edit this page on GitHub·Found a problem? Open an issue →·How to contribute →

On this page

Ask the docs
Ask anything about AgentsKit. Answers come from the docs corpus and cite their sources.