npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-ai-chat-ui

v1.0.0

Published

Reusable AI chat UI primitives for React (ChatGPT-style) — messages, markdown, code blocks, and composer.

Downloads

139

Readme

react-ai-chat-ui

Composable AI chat UI for React 19 — layout shell, message list with auto-scroll, markdown + GFM, lightweight fenced code blocks (copy + scroll, no Prism bundle), and a keyboard-friendly composer.

npm name: The name react-ai-ui is already taken on npm (another maintainer). This library is published as react-ai-chat-ui.

Install

npm install react-ai-chat-ui react react-dom

Import the bundled stylesheet once (Tailwind utilities scoped to the classes used in this package):

import "react-ai-chat-ui/styles.css";

Try it locally (demo app)

From the repo root:

npm run demo

That builds the library, installs the Vite app under examples/demo, and starts http://localhost:5173.

Two-terminal workflow (while you change library source):

  1. Terminal A — library watch: npm run dev (rebuilds dist/ on save).
  2. Terminal B — demo: cd examples/demo && npm install && npm run dev
    Refresh the browser after each library rebuild (or rely on Vite HMR when only the demo changes).

The demo depends on the library via "react-ai-chat-ui": "file:../.." in examples/demo/package.json (npm links the package into node_modules).

Verify it works

Automated sanity check (types + library build + demo production build):

npm test

All steps must exit with code 0. That proves the package compiles, bundles, and the demo app can import and build against it.

Manual smoke test (run npm run demo, then in the browser):

| Check | What to do | Pass if | |--------|------------|---------| | Styles | Open the demo | Chat shell, bubbles, and input look styled (not unstyled HTML). | | Send | Type text, click Send or press Enter | User bubble appears on the right; input clears. | | Shift+Enter | Shift+Enter in the textarea | Inserts a newline without sending. | | Empty send | Clear input, click Send | Nothing is added (button disabled when empty). | | Assistant reply | Send a message | After ~600ms, assistant bubble on the left with bold text and a code fence. | | Markdown | Confirm bold + fence render | Not raw ** or triple backticks as plain text. | | Code block | In assistant message, use horizontal scroll if needed | Monospace block; Copy works (paste elsewhere). | | Scroll | Send several messages | List scrolls toward the latest message. |

For deeper coverage later, add Vitest + React Testing Library or Playwright against examples/demo — not included yet to keep the repo minimal.

Use in another project without publishing

From this repo:

npm run build
npm pack

In your app:

npm install /absolute/path/to/react-ai-chat-ui-1.0.0.tgz

Or in your app’s package.json: "react-ai-chat-ui": "file:../path/to/this-repo" then npm install.

Bundle size

This package intentionally does not ship react-syntax-highlighter / Prism. Fenced code is readable monospace + horizontal scroll + copy, which keeps npm install and the published JS bundle small. If you need token colors, add a highlighter in your app and swap the code / pre mapping in a fork of AIMessage, or wrap CodeBlock.

Quick start

import {
  ChatWindow,
  MessageList,
  PromptInput,
  useChat,
} from "react-ai-chat-ui";
import "react-ai-chat-ui/styles.css";

function App() {
  const { messages, sendMessage, addAssistantMessage } = useChat();

  const handleSend = (text: string) => {
    sendMessage(text);
    setTimeout(() => {
      addAssistantMessage(`You said: ${text}`);
    }, 1000);
  };

  return (
    <div className="h-dvh p-4">
      <ChatWindow className="mx-auto h-full max-h-[720px]">
        <MessageList messages={messages} />
        <PromptInput onSend={handleSend} />
      </ChatWindow>
    </div>
  );
}

Exports

  • ChatWindow — flex column shell (min-h-0 safe for nested scroll)
  • MessageList — renders Message[], auto-scroll, optional footer slot
  • MessageBubble — user vs assistant layout; assistant uses AIMessage
  • AIMessagereact-markdown + remark-gfm
  • CodeBlock — monospace fence + copy + horizontal scroll (no syntax-highlighter dependency)
  • PromptInput — Enter send, Shift+Enter newline, empty guard
  • TypingIndicator — status line for loading
  • useChat — in-memory messages + sendMessage / addAssistantMessage / clearMessages
  • Types: Message, MessageRole

License

MIT