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

@brainbaseai/react-widget

v1.0.1

Published

Native React widget for Brainbase Support Agent

Readme

@brainbaseai/react-widget

The official native React chat widget and headless hook for Brainbase Support Agents.

License: MIT

Embed a full-featured, accessible AI support chat widget into your React or Next.js application in less than 2 minutes without iframes.


Features

  • 🚀 Native DOM Rendering: Zero iframes, zero layout shifting, and high performance.
  • 🎨 Auto-Themed: Automatically syncs branding colors, avatars, and welcome messages from your Brainbase dashboard.
  • 🛡️ Hardened Security: Includes XSS protections, CSS injection guards, ambient cookie isolation (credentials: 'omit'), and payload size limits.
  • 🧩 Headless Hook: Includes useBrainbaseChat to build your own custom support UI with any design system (Tailwind, shadcn/ui, MUI, etc.).
  • Accessible: WCAG compliant with ARIA roles, live regions for typing indicators, and keyboard navigation (Escape to close).

Installation

npm install @brainbaseai/react-widget @ai-sdk/react ai
# or
pnpm add @brainbaseai/react-widget @ai-sdk/react ai
# or
yarn add @brainbaseai/react-widget @ai-sdk/react ai

Note: @ai-sdk/react, ai, react, and react-dom are peer dependencies.


Quick Start (Drop-in Widget)

Add the widget to your app layout or root component:

// app/layout.tsx or src/App.tsx
import { BrainbaseWidget } from "@brainbaseai/react-widget";
import "@brainbaseai/react-widget/dist/index.css";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        {children}
        <BrainbaseWidget publishableKey="bb_live_your_key_here" />
      </body>
    </html>
  );
}

Props Reference

<BrainbaseWidget />

| Prop | Type | Default | Description | | :--- | :--- | :--- | :--- | | publishableKey | string | (Required) | The public agent key (bb_live_...) from your Brainbase dashboard. | | defaultOpen | boolean | false | Whether the chat panel starts open when mounted. |


Headless Usage (useBrainbaseChat)

For complete control over the chat interface, use the headless useBrainbaseChat hook:

'use client';

import { useBrainbaseChat } from '@brainbaseai/react-widget';

export function CustomChatWidget() {
  const {
    state,
    branding,
    messages,
    input,
    setInput,
    handleSubmit,
    isLoading
  } = useBrainbaseChat({
    publishableKey: 'bb_live_your_key_here'
  });

  if (state === 'loading') return <div>Loading support...</div>;
  if (state === 'error' || state === 'unavailable') return <div>Support unavailable</div>;

  return (
    <div className="custom-chat-window">
      <header style={{ backgroundColor: branding?.primaryColor }}>
        <h3>{branding?.title || 'Support'}</h3>
      </header>

      <div className="messages-container">
        {messages.map((m) => (
          <div key={m.id} className={m.role === 'user' ? 'user-msg' : 'bot-msg'}>
            {m.parts?.map((p) => (p.type === 'text' ? p.text : '')).join('') || (m as any).content}
          </div>
        ))}
        {isLoading && <p>Thinking...</p>}
      </div>

      <form onSubmit={(e) => {
        e.preventDefault();
        handleSubmit(e, { data: { role: 'user', parts: [{ type: 'text', text: input }] } });
        setInput('');
      }}>
        <input
          value={input}
          onChange={(e) => setInput(e.target.value)}
          placeholder="Ask a question..."
        />
        <button type="submit" disabled={isLoading || !input.trim()}>Send</button>
      </form>
    </div>
  );
}

Security Best Practices

  1. Public Key Authorization: Always use your public key (bb_live_...) in client applications. Never expose your account API keys or secrets in client code.
  2. Origin Verification: Configure allowed domains in your Brainbase Agent Dashboard to ensure your key can only be initialized on your domain.
  3. Cookie Isolation: All API requests use credentials: 'omit' to prevent cross-origin cookie sharing.

Development & Publishing

Build

npm run build

Dry Run (Verify package tarball contents)

npm pack --dry-run

Publish to NPM

npm login
npm publish --access public

License

MIT © [BrainbaseAI]