I built a 20 kB React hook that doesn't care which AI you use — here's how streaming actually works
Dev.to AI
•
Generative AI
AI Hardware
`--- Most React AI chat libraries are secretly backend libraries. They stream directly from OpenAI, or through their own cloud, or via a framework-specific server adapter. The React hook is just a thin client on top of one particular provider. Switch from Claude to GPT-4? Rewrite the frontend. Migrate off Vercel? Add Groq for a faster path? But here's the thing: streaming AI chat is fundamentally just three events: data: {"type":"text","text":"Hello"} data: {"type":"text","text":", world"} data: {"type":"done"} That's it. text, done, error.