Skip to main content

80 posts tagged with "Web Development"

Web Development Technologies and Practices

View All Tags

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 Support Light and Dark Mode with CSS Variables

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

A page can follow the light or dark setting of the visitor's computer without a line of JavaScript. Define each color once as a CSS variable, give the variables dark values inside a prefers-color-scheme media query, and use only the variables in the rest of your CSS. One more line, color-scheme, makes form fields and scroll bars follow too.

How to Stream Server-Sent Events from a Next.js Route Handler

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

Server-Sent Events let a server push updates to the browser over a normal HTTP response that stays open: progress messages, notifications, or an AI answer appearing word by word. A Next.js route handler can send them by returning a ReadableStream. This guide streams five events a second apart, shows the exact format and headers, cleans up when the client leaves, and receives the events in a page.

Self-Host Dewiride Analytics on Ubuntu Server — Part 4: Claim the Install and Add Your First Website

· 17 min read
Jagdish Kumawat
Founder @ Dewiride

Your installation is running on a real domain with a padlock, and it belongs to nobody. This part claims it with the one-time owner screen, adds your first website, and gets the tracking code onto a real site — plus the origin rule that quietly explains why nothing appears when you test on localhost.