A comprehensive React component library for building AI-powered chat interfaces and interactive threads.
npm install @superinterface/react
# or
yarn add @superinterface/react
# or
pnpm add @superinterface/reactThe root provider component that must wrap your application to enable Superinterface functionality.
import { SuperinterfaceProvider } from '@superinterface/react';
function App() {
return (
<SuperinterfaceProvider>
{/* Your app content */}
</SuperinterfaceProvider>
);
}The main component for displaying a chat thread.
import { Thread } from '@superinterface/react';
function ChatComponent() {
return <Thread />;
}A modal dialog version of the Thread component.
import { ThreadDialog } from '@superinterface/react';
function ChatDialogComponent() {
return <ThreadDialog />;
}A specialized thread component for audio-based interactions.
import { AudioThread } from '@superinterface/react';
function AudioChatComponent() {
return <AudioThread />;
}A modal dialog version of the AudioThread component.
Renders the content of a message with support for various content types.
import { MessageContent } from '@superinterface/react';
function Message({ content }) {
return <MessageContent content={content} />;
}A versatile avatar component used for both user and assistant avatars.
import { Avatar } from '@superinterface/react';
function UserAvatar() {
return <Avatar src="path/to/avatar.png" />;
}Displays suggestion chips or options to the user.
import { Suggestions } from '@superinterface/react';
function SuggestionsComponent({ suggestions }) {
return <Suggestions items={suggestions} />;
}useMessages: Fetch and manage messages in a threaduseMessageContext: Access the current message contextuseLatestMessage: Get the most recent messageuseCreateMessage: Create new messagesuseIsMutatingMessage: Track message mutation status
useThreadContext: Access the current thread contextuseThreadDialogContext: Access the thread dialog contextuseAudioThreadContext: Access the audio thread context
useAssistant: Access and manage assistant stateuseTtsAudioRuntime: Manage text-to-speech functionalityuseWebrtcAudioRuntime: Manage WebRTC audio functionality
useComponents: Access custom component overridesuseMarkdownContext: Access markdown rendering context
ComponentsProvider: Provide custom component overridesMarkdownProvider: Configure markdown renderingAssistantProvider: Provide assistant configuration
TtsAudioRuntimeProvider: Provide text-to-speech functionalityWebrtcAudioRuntimeProvider: Provide WebRTC audio functionality
AssistantAvatarContext: Configure assistant avatarAssistantNameContext: Configure assistant nameUserAvatarContext: Configure user avatarFunctionComponentsContext: Configure function UI components
Base component for rendering function calls and their results.
import { FunctionBase } from '@superinterface/react';
function CustomFunction({ data }) {
return <FunctionBase data={data} />;
}Displays the status and output of a running step or command.
import { RunStep } from '@superinterface/react';
function StepComponent({ step }) {
return <RunStep step={step} />;
}Renders source annotations for referenced content.
import { SourceAnnotation } from '@superinterface/react';
function AnnotatedContent({ source }) {
return <SourceAnnotation source={source} />;
}- Always wrap your application with
SuperinterfaceProvider - Use the appropriate context providers based on your needs
- Leverage hooks for managing state and interactions
- Use the provided UI components for consistent styling
- Implement custom components through the
ComponentsProviderwhen needed
This package includes TypeScript definitions. All components and hooks are fully typed for better development experience.
- React 18 or higher
- TypeScript 4.5 or higher (for TypeScript users)
ISC License