@deuz-sdk/react
v2.0.0
Published
React bindings for the Deuz SDK — useChat/useObject hooks and headless chat components.
Maintainers
Readme
@deuz-sdk/react
React bindings for the Deuz SDK — useChat / useObject hooks and minimal headless components on top of @deuz-sdk/core.
npm i @deuz-sdk/core @deuz-sdk/reactThin adapter by design: every chat-state transformation lives in @deuz-sdk/core/chat (the pure reducer/branch helpers) and the Deuz UI wire (@deuz-sdk/core/ui); this package only binds them to React state. react is a peer dependency (^18 || ^19). The legacy @deuz-sdk/core/react subpath keeps working but is frozen; new features land here.
API
useChat(options): UseChatResult
Options: api, initialMessages? (rendered via uiFromMessages), headers?, body?, chatId? (merged into every request body), resume? ({ endpoint, lastEventId? } — enables reconnect()), generateId?, onToolCall? (client-tool executor, auto round-trip with self-healing errors), onError?, fetch?.
Result:
- State:
messages: UIMessage[],status: 'idle' | 'streaming' | 'error',error,pendingApprovals: ToolApprovalRequest[],cost?: { costUsd, cacheSavingsUsd? },budgetExceeded?: { kind, limit, value },dataParts: { name, payload }[],citations. - Methods:
sendMessage(text),stop(),regenerate()(coredropTrailingAssistant),editAndResend(messageId, text)(corebranchBeforeUserMessage),addToolApprovalResponse(response)(auto-preserves the request's signedtoken; auto-resumes withapprovalResponsesonce every pending approval has a verdict),reconnect()(reads the resume endpoint viaconnectDeuzStream).
useObject<T>(options): UseObjectResult<T>
Streams toDeuzObjectStreamResponse output. Options: api, headers?, fetch?. Result: object (latest DeepPartial<T>), isLoading, error, submit(input), stop().
Headless components (zero styling)
ToolApprovalCard({ approval, onRespond, render? })— Approve/Deny for one pending approval; the verdict always carries the request's signedtoken.renderoverrides presentation and receives wiredapprove()/deny(reason?)callbacks.CostBadge({ cost, format? })—$X.XXXXplus(saved $Y.YYYY)when cache savings are positive;formatoverrides.
Re-exported core types
UIMessage, UIToolCall, AssistantTurnState, ChatHistory, DeuzUIPart, Message, ToolApprovalRequest, ToolApprovalResponse.
See the main README for the full SDK tour.
