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().

#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: instantiate in onMount or a client-only component; the adapter must run in the browser unless you proxy through a server endpoint.

#Source

Explore nearby

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

On this page