Skip to main content

Client SDK Overview

Octavus provides two packages for frontend integration:

PackagePurposeUse When
@octavus/reactReact hooks and bindingsBuilding React applications
@octavus/client-sdkFramework-agnostic coreUsing Vue, Svelte, vanilla JS, or custom integrations

Most users should install @octavus/react — it includes everything from @octavus/client-sdk plus React-specific hooks.

Installation

React Applications

bash

Current version: 2.20.0

Other Frameworks

bash

Current version: 2.20.0

Transport Pattern

The Client SDK uses a transport abstraction to handle communication with your backend. This gives you flexibility in how events are delivered:

TransportUse CaseDocs
createHttpTransportHTTP/SSE (Next.js, Express, etc.)HTTP Transport
createSocketTransportWebSocket, SockJS, or other socket protocolsSocket Transport

When the transport changes (e.g., when sessionId changes), the useOctavusChat hook automatically reinitializes with the new transport.

Recommendation: Use HTTP transport unless you specifically need WebSocket features (custom real-time events, Meteor/Phoenix, etc.).

React Usage

The useOctavusChat hook provides state management and streaming for React applications:

tsx

Framework-Agnostic Usage

The OctavusChat class can be used with any framework or vanilla JavaScript:

typescript

Key Features

Unified Send Function

The send function handles both user message display and agent triggering in one call:

tsx

Message Parts

Messages contain ordered parts for rich content:

tsx

Status Tracking

tsx

Stop Streaming

tsx

Retry Last Trigger

Re-execute the last trigger from the same starting point. Messages are rolled back to the state before the trigger, the user message is re-added (if any), and the agent re-executes. Already-uploaded files are reused without re-uploading.

tsx

canRetry is true when a trigger has been sent and the chat is not currently streaming or awaiting input.

Hook Reference (React)

useOctavusChat

typescript

useAutoScroll

Smart auto-scroll for chat containers. Scrolls to bottom when content updates, but pauses if the user has scrolled up. See Streaming — Auto-Scroll for full usage.

typescript

Transport Reference

createHttpTransport

Creates an HTTP/SSE transport using native fetch():

typescript

createSocketTransport

Creates a WebSocket/SockJS transport for real-time connections:

typescript

Socket transport provides additional connection management:

typescript

For detailed WebSocket/SockJS usage including custom events, reconnection patterns, and server-side implementation, see Socket Transport.

Class Reference (Framework-Agnostic)

OctavusChat

typescript

Next Steps