React SDK
Loading...
React SDK Reference
API reference for @tambo-ai/react - Tambo's React SDK with streaming-first architecture and explicit thread management.
The @tambo-ai/react package is Tambo's React SDK, featuring a streaming-first architecture, explicit thread management, and React Query integration.
Installation
npm install @tambo-ai/reactQuick Start
import { TamboProvider, useTambo, useTamboThreadInput } from "@tambo-ai/react";Quick Links
- Hooks - React hooks for thread management, messaging, suggestions, and component state
- Types - TypeScript interfaces and types
- Providers - Provider components for configuring Tambo
Overview
The React SDK is organized around a simplified provider hierarchy with React Query for data fetching:
import { TamboProvider } from "@tambo-ai/react";
function App() {
return (
<TamboProvider
apiKey={process.env.NEXT_PUBLIC_TAMBO_API_KEY}
userKey={userId}
components={
[
/* your components */
]
}
tools={
[
/* your tools */
]
}
>
<YourApp />
</TamboProvider>
);
}Inside the provider, use hooks to access Tambo functionality:
import { useTambo, useTamboThreadInput } from "@tambo-ai/react";
function Chat() {
const { messages, isStreaming, startNewThread } = useTambo();
const { value, setValue, submit } = useTamboThreadInput();
return (
<div>
{messages.map((msg) => (
<Message key={msg.id} message={msg} />
))}
<input
value={value}
onChange={(e) => setValue(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && submit()}
/>
</div>
);
}Key Features
| Feature | Implementation |
|---|---|
| Import path | @tambo-ai/react |
| Main hook | useTambo() |
| User scoping | userKey prop |
| Thread input | useTamboThreadInput() |
| Message format | Content blocks (text, component, tool_use, etc.) |
| Component state | useTamboComponentState() (bidirectional sync) |
| Streaming status | streamingState.status (typed as RunStatus) |
| Data fetching | React Query hooks |
Component Props and Performance
Learn how to structure component props and Zod schemas so Tambo generates smaller payloads, faster responses, and more efficient generative UI in React.
React SDK Hooks
Complete reference for @tambo-ai/react hooks - thread management, messaging, suggestions, and component state.