METABYTE
Back to articles

20 KB React hook that doesn't care which AI you use — streaming made simple

A dev built a hook that abstracts streaming from any AI provider, so switching models is just a URL change away.

10 mai 20262 min read
20 KB React hook that doesn't care which AI you use — streaming made simple

Most React AI chat libraries are secretly backend libraries in disguise. They stream directly from the provider, locking you in tighter than a legacy jQuery plugin. But one developer decided enough is enough and created a tiny 20 KB hook that works with any AI.

How it works? Instead of pulling in heavy SDKs from OpenAI or Anthropic, the hook uses native EventSource and transparent stream parsing. You just pass your endpoint URL, and it handles chunking, token streaming, and response assembly. No magic — just honest streaming without bloat.

If you've ever felt the pain of "Oh, a new model dropped, time to update the SDK", this hook is a breath of fresh air: it works with any AI that outputs streamed data. Want to switch from GPT-4 to Claude? Just change the URL in your config. No midnight deployments, no praying.

Sure, it doesn't have fancy features like auto-reconnect or complex error handling — it's a minimalist tool for those who love control. But as a foundation for a custom AI chat, it's spot on.

METABYTE studio comment: We love such solutions — lightweight, flexible, and without over-engineering. If your next project involves AI integration, don't bloat your bundle with tons of SDKs. Drop us a line: we'll help you build streaming that won't break when you switch models (and won't eat your FPS).

NEXT STEP

Liked the approach?

We apply the same principles to client projects: AI, automation, products that don't die after launch.