@inkly/svelte
v0.0.0
Published
Official Svelte bindings for inkly: stores over the typed client.
Readme
@inkly/svelte
Official Svelte stores for inkly. The package wraps one @inkly/client instance with framework-agnostic stores and helpers.
Install
pnpm add @inkly/svelte @inkly/client @inkly/protocol svelteQuickstart
import { createSvelteClient } from "@inkly/svelte";
import { chat } from "./shared/contract";
export const inkly = createSvelteClient(chat, { url: "wss://api.example.com/ws" });<script lang="ts">
import { inkly } from "./inkly";
const status = inkly.status;
const send = inkly.action("sendMessage");
const assistant = inkly.stream("assistant", { prompt: "Hello" });
</script>
<p>Connection: {$status}</p>
<button disabled={$send.isPending} on:click={() => send.mutate({ text: "Hi" })}>Send</button>API
createSvelteClient(contract, options)creates a client and stores.createInklyStores(client)wraps an existing client.statusis a readable store of the client status.action(name)returns{ data, error, isPending, call, mutate }stores/functions.event(name, handler?)returns a readable store for the latest payload and optionally calls a handler.stream(name, input)returns a readable{ items, status, error, cancel }stream state.
Cleanup guarantee
Svelte start/stop notifiers attach listeners only while stores are subscribed. The final unsubscribe removes status/event listeners and cancels active streams.
