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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@useknest/widget-react

v0.0.1-alpha.11

Published

Native React component for Knest chat widget

Readme

@useknest/widget-react

Native React component for the Knest chat widget with streaming support.

Installation

npm install @useknest/widget-react
# or
pnpm add @useknest/widget-react
# or
yarn add @useknest/widget-react

Usage

Basic Example

import { ChatWidget } from '@useknest/widget-react';

function App() {
	return (
		<div>
			<ChatWidget publishableApiKey="pk_your_key_here" />
		</div>
	);
}

That's it! Styles are automatically included - no separate CSS import needed.

Props

ChatWidget

| Prop | Type | Required | Description | | ------------------- | -------- | -------- | ---------------------------------- | | publishableApiKey | string | Yes | Your project's publishable API key |

Features

  • Native React Component - Built with React hooks, no web component wrapper
  • Streaming Support - Real-time message streaming via Server-Sent Events (SSE)
  • TypeScript - Full TypeScript support with exported types
  • Customizable - Fetches branding (avatar, colors, welcome message) from your project config
  • Lightweight - ~28KB minified (~8.5KB gzipped)
  • Framework-Agnostic Core - Shares business logic with other platform packages

TypeScript

The package includes TypeScript definitions. You can import types:

import { ChatWidget, type ChatWidgetProps, type Message } from '@useknest/widget-react';

Customization

The widget automatically loads customization from your project's configuration:

  • Avatar image
  • Brand color
  • Welcome message
  • Example questions

No additional props needed - just provide your publishableApiKey.

Architecture

This package uses @useknest/widget-core for all business logic (API calls, streaming, markdown rendering). The React component handles only the UI rendering with React-specific optimizations.

Benefits:

  • Efficient re-renders during streaming
  • Native React state management
  • React DevTools compatibility
  • Optimized bundle size

Browser Support

  • Modern browsers (Chrome, Firefox, Safari, Edge)
  • Requires native ES modules support
  • Requires EventSource API for streaming (available in all modern browsers)

Examples

Full-Height Widget

import { ChatWidget } from '@useknest/widget-react';
import '@useknest/widget-react/dist/widget-react.css';

function FullPageChat() {
	return (
		<div style={{ height: '100vh', width: '100vw' }}>
			<ChatWidget publishableApiKey="pk_your_key_here" />
		</div>
	);
}

Widget in a Container

import { ChatWidget } from '@useknest/widget-react';
import '@useknest/widget-react/dist/widget-react.css';

function ChatContainer() {
	return (
		<div style={{ maxWidth: '900px', height: '600px', margin: '0 auto' }}>
			<ChatWidget publishableApiKey="pk_your_key_here" />
		</div>
	);
}

Troubleshooting

Streaming not working

Solution: Check that your backend API is running and accessible. The widget defaults to http://localhost:5173/api/v1 for local development.

TypeScript errors

Solution: Make sure you have React types installed:

npm install --save-dev @types/react @types/react-dom

License

MIT

Support

For issues and questions, please visit GitHub Issues.