Who it is forA front-end developer building a chat screen where the model answer arrives in chunks over a streaming HTTP response.
The problemRe-rendering streamed text often replays animations on content that already appeared, which is distracting and hard to read.
The outcomeThe answer grows as chunks arrive, previously received text stays still, and the live status announces received text to assistive technology.
What you need first
- Node.js and npm to install the package
- A React app using React 18 or newer
- A streaming or pending response source, such as a fetch endpoint, for the text and status cases
Steps
- Run
npm install generative-loadersin the React project. - Import TextLoader from Generative Loaders and import generative-loaders/styles.css once near the application root.
- Keep the full response received so far in React state and append each decoded chunk to it.
- Render TextLoader with the full text and one of the text variants, such as decode or typewriter.
- Stream a test response from your endpoint and confirm earlier text does not reanimate as new chunks arrive.
Prompt for your agent
In the generative-loaders repo (kasturibuilds/generative-loaders), wire TextLoader into the chat component at <path-to-component> so it renders the full response text received so far from a streaming fetch. Expected output: a short diff and a note on which text variant was chosen. Verify that the component passes the complete accumulated string, not only the newest chunk.
Caveat. The README asks you to pass the complete response received so far, so a component that sends only the newest token will not show the intended behavior.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for kasturibuilds/generative-loaders and "Stream AI answers into a React chat with TextLoader"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer