React hooks and components for AI Kit
npm install @ainative/ai-kit-reactThe React package provides:
- Hooks:
useAIStream,useConversation - Components:
ChatInterface,MessageList,UsageDashboard,CodeBlock - Component Registry: Custom tool result rendering
- Hooks - React hooks for AI functionality
- Components - Pre-built UI components
- Component Registry - Custom component registration
import { useAIStream } from '@ainative/ai-kit-react';
function ChatApp() {
const {
messages,
isStreaming,
send,
reset
} = useAIStream({
endpoint: '/api/chat',
model: 'gpt-4'
});
return (
<div>
{messages.map(msg => (
<div key={msg.id}>{msg.content}</div>
))}
<button onClick={() => send('Hello!')}>Send</button>
</div>
);
}