A drop-in replacement for @ai-sdk/react with 3-5x performance improvements. Built-in optimizations, O(1) message lookups, batched updates, and zero configuration required.
npm install @ai-sdk-tools/storeSay goodbye to prop drilling. Access chat state from any component in your app without passing props through multiple layers.
Components only re-render when their specific data changes. Better performance through selective subscriptions and state isolation.
Create custom selectors for any derived state with full TypeScript support and complete type safety throughout your application.
Drop-in replacement with the exact same API. Migrate in seconds without changing any existing code or component structure.
Full support for custom message types, tool calls, and metadata with the same great developer experience you're used to.
Built on Zustand for reliable, performant global state that works seamlessly with React's concurrent features and SSR.
// Chat.tsx - Everything in one place import { useChat } from '@ai-sdk/react' import { DefaultChatTransport } from 'ai' function Chat() { const { messages, sendMessage, isLoading } = useChat({ transport: new DefaultChatTransport({ api: '/api/chat' }) }) // Pass everything as props return ( <div> <Header chatCount={messages.length} /> <MessageList messages={messages} /> <MessageInput onSend={sendMessage} disabled={isLoading} /> <StatusBar isLoading={isLoading} /> <Sidebar messages={messages} /> </div> ) } // Props drilling nightmare! // Every component needs props passed down
// App.tsx - Wrap with Provider import { Provider } from '@ai-sdk-tools/store' function App() { return ( <Provider initialMessages={[]}> <Chat /> </Provider> ) } // Chat.tsx - High-performance chat (3-5x faster!) import { useChat } from '@ai-sdk-tools/store' import { DefaultChatTransport } from 'ai' function Chat() { const { messages, sendMessage, status } = useChat({ transport: new DefaultChatTransport({ api: '/api/chat' }) }) // No props needed - state available everywhere! return ( <div> <Header /> <MessageList /> <MessageInput /> <StatusBar /> <Sidebar /> </div> ) } // MessageList.tsx - O(1) message access function MessageList() { const messages = useChatMessages() // O(1) lookups! const status = useChatStatus() return ( <div> {messages.map(msg => ( <div key={msg.id}>{msg.content}</div> ))} {status === 'streaming' && <div>AI thinking...</div>} </div> ) }
Drop-in replacement for @ai-sdk/react with global state management.