Types
The React SDK re‑uses most of its types from @orga-ai/core, adding a few React‑specific extensions for hooks and components.
React‑specific Types
OrgaAIHookReturn
Shape of the object returned by useOrgaAI().
export interface OrgaAIHookReturn {
// Session management
startSession: (config?: SessionConfig) => Promise<void>;
endSession: () => Promise<void>;
// Media controls
enableMic: () => Promise<void>;
disableMic: (hardDisable?: boolean) => Promise<void>;
toggleMic: () => Promise<void>;
enableCamera: () => Promise<void>;
disableCamera: (hardDisable?: boolean) => Promise<void>;
toggleCamera: () => Promise<void>;
// State
connectionState: ConnectionState;
aiAudioStream: MediaStream | null;
userAudioStream: MediaStream | null;
userVideoStream: MediaStream | null;
conversationItems: ConversationItem[];
isCameraOn: boolean;
isMicOn: boolean;
conversationId: string | null;
// Parameter management
model: OrgaAIModel | null;
voice: OrgaAIVoice | null;
temperature: number | null;
instructions: string | null;
modalities: Modality[];
updateParams: (params: {
model?: OrgaAIModel;
voice?: OrgaAIVoice;
temperature?: number;
instructions?: string;
modalities?: Modality[];
}) => void;
}| Field | Type | Description |
|---|---|---|
startSession | (config?: SessionConfig) => Promise<void> | Starts a session and handles credential negotiation. |
endSession | () => Promise<void> | Ends the current session and cleans up transport and media. |
enableMic, disableMic, toggleMic | Functions | Control microphone state and permissions. |
enableCamera, disableCamera, toggleCamera | Functions | Control camera stream state. |
connectionState | ConnectionState | "disconnected" | "connecting" | "connected". |
aiAudioStream, userAudioStream, userVideoStream | MediaStream | null | Current input/output streams managed by the SDK. |
conversationItems | ConversationItem[] | Messages and transcripts in the active session. |
isCameraOn, isMicOn | boolean | Flags reflecting current device states. |
conversationId | string | null | ID of the active conversation. |
model, voice, temperature, instructions, modalities | Various core types | Reflect the active session configuration. |
updateParams | (params) => void | Dynamically update session configuration during a live connection. |
IceCandidateEvent
Event wrapper emitted when ICE candidates update.
export type IceCandidateEvent = {
candidate: RTCIceCandidate | null;
};Re‑exported Core Types
For convenience, the React SDK re‑exports many types from @orga-ai/core so you don’t need a second import.
| Type | Description |
|---|---|
ConnectionState | Connection lifecycle states. |
OrgaAIModel | Supported model names. |
OrgaAIVoice | Supported voice presets. |
Modality | Active media types: "audio", "video". |
ConversationItem | Represent individual conversation entries. |
SessionConfig | Full set of connection and session parameters. |
OrgaAIHookCallbacks | Optional callbacks fired during session lifecycle. |
SessionCreatedEvent, ConversationCreatedEvent | Event payloads delivered through DataChannels. |
DataChannelEvent | Lower‑level DataChannel event payload. |
DataChannelEventTypes (enum) | String constants identifying event types. |
To explore foundational types in detail, see the
@orga-ai/corereference →.
Example Usage
import type { OrgaAIHookReturn, ConnectionState } from "@orga-ai/react";
import { useOrgaAI } from "@orga-ai/react";
export default function Example() {
const { startSession, connectionState } = useOrgaAI() as OrgaAIHookReturn;
return (
<div>
<p>State: {connectionState}</p>
<button onClick={() => startSession()}>Start</button>
</div>
);
}This example shows how to use the provided types to safely infer method signatures and state values in a TypeScript React app.
Next Steps
- Hooks → Control sessions, devices, permissions, and AI interactions using
useOrgaAI(). - Components → UI primitives such as
<OrgaAIProvider>and media components. - Core Type Reference → TypeScript types and enums exported by the SDK.
Last updated on