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.9.0

Other Frameworks

bash

Current version: 2.9.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

Hook Reference (React)

useOctavusChat

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