Sign In

@neeter/react

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neeter/react - npm Package Compare versions

Comparing version
0.10.0
to
0.10.1
+7
-0
dist/AgentProvider.d.ts

@@ -8,5 +8,12 @@ import type { CustomEvent } from "@neeter/types";

}
/**
* Context provider that creates a Zustand store and wires up the SSE connection.
* Wrap your chat UI with this — children access the store via `useAgentContext()`.
*/
export declare function AgentProvider(props: {
/** Base URL for the neeter server routes. Defaults to `"/api"`. */
endpoint?: string;
/** SDK session ID to resume on mount. Replays persisted events then reconnects. */
resumeSessionId?: string;
/** Handler for custom events emitted by `onToolResult` on the server. */
onCustomEvent?: (event: CustomEvent) => void;

@@ -13,0 +20,0 @@ children: ReactNode;

+4
-0

@@ -7,2 +7,6 @@ import { jsx as _jsx } from "react/jsx-runtime";

const AgentContext = createContext(null);
/**
* Context provider that creates a Zustand store and wires up the SSE connection.
* Wrap your chat UI with this — children access the store via `useAgentContext()`.
*/
export function AgentProvider(props) {

@@ -9,0 +13,0 @@ const storeRef = useRef(null);

import type { WidgetRegistration } from "./types.js";
/**
* Register a component for a tool name. Must run before React renders any
* tool calls — use a side-effect import at your app's entry point.
* Later registrations overwrite earlier ones for the same `toolName`.
*/
export declare function registerWidget<TResult>(reg: WidgetRegistration<TResult>): void;
export declare function getWidget(toolName: string): WidgetRegistration | undefined;
export declare function stripMcpPrefix(name: string): string;
const widgets = new Map();
/**
* Register a component for a tool name. Must run before React renders any
* tool calls — use a side-effect import at your app's entry point.
* Later registrations overwrite earlier ones for the same `toolName`.
*/
export function registerWidget(reg) {

@@ -3,0 +8,0 @@ widgets.set(reg.toolName, reg);

@@ -39,4 +39,13 @@ import type { ChatMessage, PermissionRequest, SSEEvent } from "@neeter/types";

export type ChatStore = StoreApi<ChatStoreShape>;
/**
* Creates a vanilla Zustand store for chat state. `AgentProvider` creates one
* internally — use this directly only for custom provider implementations.
*/
export declare function createChatStore(): ChatStore;
/**
* Reconstructs chat store state from persisted SSE events. Uses the same
* store actions as the live SSE stream, so rendering is identical.
* Call before connecting the EventSource (e.g. during session resume).
*/
export declare function replayEvents(store: ChatStore, events: SSEEvent[]): void;
export {};

@@ -15,2 +15,6 @@ import { immer } from "zustand/middleware/immer";

}
/**
* Creates a vanilla Zustand store for chat state. `AgentProvider` creates one
* internally — use this directly only for custom provider implementations.
*/
export function createChatStore() {

@@ -170,2 +174,7 @@ return createStore()(immer((set) => ({

}
/**
* Reconstructs chat store state from persisted SSE events. Uses the same
* store actions as the live SSE stream, so rendering is identical.
* Call before connecting the EventSource (e.g. during session resume).
*/
export function replayEvents(store, events) {

@@ -172,0 +181,0 @@ const s = store.getState();

@@ -22,2 +22,7 @@ import type { CustomEvent, PermissionResponse, SessionHistoryEntry } from "@neeter/types";

}
/**
* Low-level hook that manages the EventSource lifecycle and feeds SSE events
* into the Zustand store. Most apps should use `AgentProvider` instead —
* this hook is for custom provider implementations.
*/
export declare function useAgent(store: ChatStore, config?: UseAgentConfig): UseAgentReturn;
import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react";
import { replayEvents } from "./store.js";
/**
* Low-level hook that manages the EventSource lifecycle and feeds SSE events
* into the Zustand store. Most apps should use `AgentProvider` instead —
* this hook is for custom provider implementations.
*/
export function useAgent(store, config) {

@@ -4,0 +9,0 @@ const endpoint = config?.endpoint ?? "/api";

+2
-2
{
"name": "@neeter/react",
"version": "0.10.0",
"version": "0.10.1",
"description": "React components and hooks for building chat UIs on top of the Claude Agent SDK",

@@ -29,3 +29,3 @@ "license": "MIT",

"tailwind-merge": "^3.4.0",
"@neeter/types": "0.10.0"
"@neeter/types": "0.10.1"
},

@@ -32,0 +32,0 @@ "peerDependencies": {

@@ -67,13 +67,2 @@ # @neeter/react

## Key features
- **11 built-in widgets** — Diff views for edits, code blocks for reads, expandable pills for web searches, and more. Auto-registered on import.
- **Custom widgets** — Register your own components for MCP tools or app-specific rendering with `registerWidget()`.
- **Tool call lifecycle** — Each tool moves through `pending` → `streaming_input` → `running` → `complete` with streaming JSON input.
- **Permissions UI** — `ToolApprovalCard` and `UserQuestionCard` for browser-side tool approval.
- **Extended thinking** — Collapsible thinking blocks with streaming text.
- **Session resume** — Resume past sessions with `resumeSession()`, start fresh with `newSession()`, and browse history with `refreshHistory()`. `replayEvents` reconstructs the chat UI from persisted events.
- **Custom events** — Handle app-specific events from `onToolResult` via `AgentProvider`'s `onCustomEvent` prop.
- **Abort** — Stop the agent mid-turn with `stopSession()` from `useAgentContext()`.
## Examples

@@ -88,5 +77,6 @@

- [Full API reference](https://github.com/quantumleeps/neeter#readme)
- [Built-in widgets](https://github.com/quantumleeps/neeter/blob/main/docs/built-in-widgets.md)
- [Custom widgets](https://github.com/quantumleeps/neeter/blob/main/docs/custom-widgets.md)
- [Client Guide](https://github.com/quantumleeps/neeter/blob/main/docs/client.md) — styling, custom events, widgets, tool lifecycle
- [API Reference](https://github.com/quantumleeps/neeter/blob/main/docs/api-reference.md) — all exports and types
- [Built-in Widgets](https://github.com/quantumleeps/neeter/blob/main/docs/built-in-widgets.md)
- [Custom Widgets](https://github.com/quantumleeps/neeter/blob/main/docs/custom-widgets.md)

@@ -93,0 +83,0 @@ ## License