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

@tomiezhang/flowchat-react

v1.0.0

Published

A beautiful and customizable WebSocket chat component for React with theme support

Readme

FlowChat React

npm version React TypeScript License

A beautiful and customizable WebSocket chat component for React

Real-time messaging with theme support, streaming responses, and complete TypeScript integration

📦 Installation🚀 Quick Start📖 API Reference🎨 Themes


✨ Features

  • 🎯 TypeScript First - Complete type safety and excellent IDE support
  • 🎨 Theme System - Built-in light/dark themes with full customization
  • WebSocket Integration - Real-time messaging with auto-reconnection
  • 📱 Responsive Design - Works seamlessly across all devices
  • 🔄 Streaming Support - Real-time message streaming with visual indicators
  • 🛠 Highly Configurable - Extensive configuration options for all use cases
  • 📦 Lightweight - Minimal dependencies, optimized bundle size

Installation

npm install @tomiezhang/flowchat-react
# or
yarn add @tomiezhang/flowchat-react
# or
pnpm add @tomiezhang/flowchat-react

Quick Start

import { FlowChat } from '@tomiezhang/flowchat-react'
import type { FlowChatConfig } from '@tomiezhang/flowchat-react'

function App() {
  const config: FlowChatConfig = {
    websocketUrl: 'ws://localhost:8080',
    title: 'My AI Assistant',
    theme: 'light'
  }

  return <FlowChat config={config} />
}

With Callbacks

import { FlowChat } from '@tomiezhang/flowchat-react'

function App() {
  const handleMessage = (message: string) => {
    console.log('User sent:', message)
  }

  const handleConnectionChange = (status: 'connecting' | 'connected' | 'disconnected') => {
    console.log('Connection status:', status)
  }

  return (
    <FlowChat 
      config={{
        websocketUrl: 'ws://localhost:8080',
        title: 'Smart Assistant',
        theme: 'dark',
        height: '600px'
      }}
      onMessage={handleMessage}
      onConnectionChange={handleConnectionChange}
    />
  )
}

API Reference

FlowChatConfig

| Property | Type | Default | Description | |----------|------|---------|-------------| | websocketUrl | string | 'ws://localhost:8080' | WebSocket server URL | | autoReconnect | boolean | true | Enable automatic reconnection | | title | string | 'FlowChat' | Chat header title | | subtitle | string | 'Another AI chat interface' | Chat header subtitle | | placeholder | string | 'Type your message...' | Input placeholder text | | theme | 'light' \| 'dark' | 'light' | UI theme | | height | string | '100vh' | Component height | | showConnectionStatus | boolean | true | Show connection indicator | | showMessageCount | boolean | true | Show message count | | enableTypingIndicator | boolean | true | Show typing animation | | headerClassName | string | undefined | Custom header CSS classes | | containerClassName | string | undefined | Custom container CSS classes |

Props

| Property | Type | Description | |----------|------|-------------| | config | FlowChatConfig | Configuration object | | onMessage | (message: string) => void | Callback when user sends message | | onConnectionChange | (status: string) => void | Callback when connection status changes |

Themes

Built-in Themes

Light Theme

<FlowChat config={{ theme: 'light' }} />

Dark Theme

<FlowChat config={{ theme: 'dark' }} />

Custom Styling

Override styles using CSS classes:

<FlowChat 
  config={{
    headerClassName: 'bg-gradient-to-r from-blue-500 to-purple-600',
    containerClassName: 'border-2 border-blue-200 rounded-xl shadow-2xl'
  }}
/>

Advanced Usage

Individual Components

import { 
  ChatInterface, 
  MessageList, 
  MessageInput,
  ThemeProvider 
} from '@tomiezhang/flowchat-react'

function CustomChat() {
  return (
    <ThemeProvider theme="dark">
      <div className="custom-chat-container">
        <MessageList 
          messages={messages} 
          showTypingIndicator={false} 
          streamingMessageId={null} 
        />
        <MessageInput 
          onSendMessage={handleSend} 
          isLoading={false} 
          placeholder="Type here..." 
        />
      </div>
    </ThemeProvider>
  )
}

WebSocket Hook

import { useWebSocketChat } from '@tomiezhang/flowchat-react'

function useCustomChat() {
  const {
    messages,
    isLoading,
    connectionStatus,
    sendMessage
  } = useWebSocketChat({
    url: 'ws://your-server.com:8080',
    autoReconnect: true
  })

  return { messages, isLoading, connectionStatus, sendMessage }
}

WebSocket Protocol

The component expects WebSocket messages in this format:

// Welcome message
{
  type: 'welcome',
  data: {
    id: string,
    content: string,
    timestamp: string
  }
}

// Streaming start
{
  type: 'stream_start',
  data: {
    id: string,
    timestamp: string
  }
}

// Streaming chunk
{
  type: 'stream_chunk',
  data: {
    content: string
  }
}

// Streaming end
{
  type: 'stream_end',
  data: {
    id: string,
    content: string,
    timestamp: string
  }
}

CSS Requirements

This component uses Tailwind CSS. Ensure Tailwind is installed in your project:

npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p

TypeScript Support

Full TypeScript support is included. All types are exported:

import type { 
  FlowChatConfig,
  ChatTheme,
  Message,
  ChatState 
} from '@tomiezhang/flowchat-react'

Examples

Basic Chat

<FlowChat config={{ websocketUrl: 'ws://localhost:3001' }} />

Customized Chat

<FlowChat 
  config={{
    websocketUrl: 'ws://localhost:3001',
    title: 'Customer Support',
    subtitle: 'How can we help you?',
    theme: 'dark',
    height: '500px',
    placeholder: 'Ask us anything...'
  }}
/>

With Event Handlers

<FlowChat 
  config={{ websocketUrl: 'ws://localhost:3001' }}
  onMessage={(msg) => analytics.track('message_sent', { message: msg })}
  onConnectionChange={(status) => setConnectionStatus(status)}
/>

Browser Support

  • Chrome/Edge 88+
  • Firefox 85+
  • Safari 14+

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

v1.0.0

  • Initial release
  • WebSocket integration
  • Theme support
  • TypeScript support
  • Streaming messages

Made with ❤️ by Tomie Zhang

⭐ Star on GitHub🐛 Report Bug💡 Request Feature