@skaile/workspace-bridge-react
v0.8.5
Published
React 18+ bindings for @skaile/workspaces (useAgentStore, useResourceClient, useSubscribableStore)
Readme
@skaile/workspace-bridge-react
React 18+ bindings for @skaile/workspaces. Provides hooks for subscribing to the framework-agnostic AgentStore and ResourceClient via React's useSyncExternalStore.
Install
bun add @skaile/workspaces @skaile/workspace-bridge-react reactUsage
import { useAgentStore, useAgentStoreActions } from "@skaile/workspace-bridge-react";
import type { AgentStore } from "@skaile/workspaces/store";
function ChatPanel({ store }: { store: AgentStore }) {
const { messages, streamingText, phase } = useAgentStore(store);
const { prompt, cancel } = useAgentStoreActions(store);
return /* ... */;
}Exports
| Hook | Returns | Notes |
|---|---|---|
| useSubscribableStore<T>(store) | T | Generic — works for any SubscribableStore<T> |
| useAgentStore(store) | AgentStoreSnapshot | Convenience wrapper around useSubscribableStore |
| useAgentStoreActions(store) | { prompt, reply, cancel, loadPreviousMessages, setStatus } | Memoised by store identity |
| useResourceClient(client) | ResourceClientSnapshot | Convenience wrapper around useSubscribableStore |
Peer Dependency
react>= 18 (usesuseSyncExternalStore)
