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

@connexup/ai-chat

v1.1.9

Published

AI chat UI with native HTML, powered by @connexup/ai-api and @connexup/ai-react

Readme

AI Chat

AI chat component library with native HTML + Tailwind CSS (built into the package), powered by @connexup/ai-api and @connexup/ai-react.

Install

pnpm add @connexup/ai-chat @connexup/ai-react @connexup/ai-api lucide-react react-markdown remark-gfm

Usage

import { AiChat } from '@connexup/ai-chat';
import '@connexup/ai-chat/styles.css';

export function App() {
  return (
    <AiChat
      baseUrl="https://api.example.com"
      apiKey="your-api-key"
      accessAgents={agents}
      createSessionRequest={{ agent_id: 'my-agent-123' }}
      refreshApiKey={async () => {
        // Return a new API key when SSE reports invalid credentials.
        return await fetchNewApiKey();
      }}
    />
  );
}

Styles: Import @connexup/ai-chat/styles.css once. Tailwind utilities are pre-compiled and scoped under .ai-chat, with a built-in scoped reset for common HTML elements (button, input, hr, markdown tags, etc.) so host global styles are less likely to leak in.

If your app also uses Tailwind, pick one approach:

  • Import @connexup/ai-chat/styles.css (recommended), or
  • Add the package to your content scan — don't do both.

Key props

| Prop | Description | |------|-------------| | baseUrl | API base URL | | apiKey | Bearer token for API requests | | accessAgents | Agent list for the agent selector | | sessionId | Optional initial session to open | | createSessionRequest | Default payload when creating a session | | defaultAgentId | Agent selected before the user picks one | | loadHistoryOnConnect | Load history when sessionId is provided | | refreshApiKey | () => Promise<string> — refresh token and retry send on SSE unauthorized | | showSessionSidebar | Show chat session sidebar (default true) | | showAgentSelector | Show agent picker (default true) |

Token refresh on SSE unauthorized

When the stream returns an SSE error event:

{
  "type": "error",
  "errorCode": "UNAUTHORIZED",
  "message": "invalid api key"
}

and refreshApiKey is provided, useAiChat will:

  1. Call refreshApiKey() to obtain a new key
  2. Update AiLib / SessionApi via setApiKey
  3. Retry the same message once (per send)

If refresh fails or no refreshApiKey is passed, the error is shown in the chat as usual.

Error messages

formatApiError maps HTTP-style errors for display:

| Condition | Message | |-----------|---------| | APIException status 401 | Unauthorized | | APIException status 429 | The token limit has been used up. Please try again tomorrow | | Other | Server message or fallback |

REST errors from @connexup/ai-api are thrown as APIException when an HTTP response is available. Pure network / CORS failures surface as NetworkConnectionException (no status code in JS).

Headless hook

import { useAiChat } from '@connexup/ai-chat';

const {
  chatState,
  sendMessage,
  approveToolCall,
  startNewChat,
  openChatSession,
  chatSessions,
} = useAiChat({
  baseUrl,
  apiKey,
  sessionId,
  refreshApiKey: async () => nextApiKey,
});

Development

pnpm --filter @connexup/ai-chat run dev:css   # watch Tailwind
pnpm --filter @connexup/ai-chat run dev       # watch TS

See also examples/sse-demo for a full Vite demo.