Skip to main content

10 posts tagged with "React.js"

React.js Library for Building User Interfaces

View All Tags

How to Add a Stop Button to an AG-UI Chat

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

A long AI answer needs a way out: a Stop button that ends it where it is. With the AG-UI TypeScript client, the stop itself is one call, abortRun(). Around it, the page needs to know when a run is going, show Stop instead of Send, and not mistake the stop for an error. This guide adds all of that to a React chat and shows the result.

How to Customize the Request an AG-UI HttpAgent Sends

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

HttpAgent from @ag-ui/client sends a complete AG-UI request on every run: the whole conversation, tools, state and more. That's right for talking to an AG-UI server directly, but not for a server route that accepts only a few fields — or an agent that keeps its own history. HttpAgent builds each request in a method you can override, requestInit. This guide shows the default body, the override, and the real bodies before and after.

How to Keep a Chat Scrolled to the Newest Message in React

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

In a chat, new messages — and the words of an answer that streams in — appear at the bottom. Once the conversation is taller than its box, they appear below what people can see, unless the box scrolls with them. In React that takes an empty element at the end of the list, a ref to it, and one useEffect. This guide builds a list that grows like a streamed answer and compares it with and without the effect.

How to Send a Message with Enter and Add a New Line with Shift+Enter in React

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Chat boxes have a convention: Enter sends the message, Shift+Enter starts a new line. A <textarea> does the opposite by default — Enter adds a line, and nothing sends. One onKeyDown handler swaps the two, and one more check keeps it from interrupting people who type with an input method, as for Japanese or Chinese. This guide builds the box and tests it in a real browser.

How to Open Markdown Links in a New Tab with react-markdown

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

In a chat or a comment thread, a click on a link inside a Markdown answer shouldn't take people away from the page. react-markdown lets you replace how any element is drawn through its components option, so one small function makes every link open in a new tab. This guide shows the function, the HTML it produces, and one detail that's easy to miss: the node prop.

How to Render Markdown Safely in React with react-markdown

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

AI models and users write Markdown: numbered steps, bold words, tables, links. Shown as plain text, it's a mess of stars and pipes; turned into HTML and inserted with dangerouslySetInnerHTML, it can run whatever script someone slipped in. react-markdown turns Markdown into React elements instead. This guide renders a tricky piece of Markdown and shows what happens to the HTML and the script link inside it.

How to Keep Server-Only Code Out of the Browser in Next.js

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

In a Next.js app, the same file can be imported by code that runs on the server and by code that runs in the browser. One import "server-only" line at the top of a module that handles secrets makes the build fail the moment a Client Component imports it. This guide shows the line, the error it produces, what ships to the browser without it, and the right way to give a Client Component what it needs.

Fixed: "signal is aborted without reason" After Stopping an AG-UI Run

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

My chat page had a Stop button that calls abortRun() on its AG-UI agent. Pressing it stopped the answer — and showed signal is aborted without reason in red, as if something had failed. That text is the browser's wording for a cancelled request: @ag-ui/client 1.0.4 ends a stopped run with its own RUN_ERROR event, code abort. Skipping that one code fixed it.