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

@docgenlab.com/chat-widget

v0.5.1

Published

Embeddable AI knowledge chat widget for DocGenLab — drop into any site to give end-users a grounded RAG assistant.

Downloads

135

Readme

@docgenlab.com/chat-widget

Embeddable AI knowledge-base chat widget for DocGenLab. Drop into any site to give your end-users a grounded, citation-backed assistant.

Features

  • Floating launcher + chat panel (bottom-right or bottom-left)
  • Streaming responses over Server-Sent Events
  • Citation chips for every answer (sources linked to your KB documents)
  • Optional image attachment (PNG/JPEG/WebP/GIF, max 10 MB)
  • Mobile bottom-sheet layout under 480px
  • Theme override (primary color, font, radius)
  • Conversation persistence across page reloads (per-browser via localStorage)
  • No external CSS framework — scoped class names, no global pollution

Security model

The agentKey you embed is a publishable key (pk_live_...). It will appear in the network tab. Like Stripe's publishable key, this is by design — security comes from:

  1. Domain allowlist — register the customer's site domains against the key in your DocGenLab dashboard. Requests from other Origins are rejected.
  2. Rate limit — per-key and per-IP, enforced server-side.
  3. Org-level monthly quota — hard cap on total queries.

Never put a secret key (sk_live_...) in client code.

Install

npm install @docgenlab.com/chat-widget

Usage (React / Next.js / Vue / Svelte etc.)

import { DocGenLabChat } from '@docgenlab.com/chat-widget';
import '@docgenlab.com/chat-widget/style.css';

export function MyApp() {
    return (
        <DocGenLabChat
            agentKey="pk_live_..."
            position="bottom-right"
            theme={{ primary: '#7C3AED' }}
            greeting="Hi! Ask me anything about our product."
        />
    );
}

Usage (vanilla HTML — WordPress, marketing pages, anything without a build)

<link rel="stylesheet" href="https://unpkg.com/@docgenlab.com/chat-widget/dist/widget.css" />
<script src="https://unpkg.com/@docgenlab.com/chat-widget"></script>
<script>
    DocGenLab.init({
        agentKey: 'pk_live_...',
        position: 'bottom-right',
        theme: { primary: '#7C3AED' },
    });
</script>

To remove the widget later (e.g. on a sign-out page):

DocGenLab.destroy();

Configuration

| Prop | Type | Default | Description | |---|---|---|---| | agentKey | string | required | The pk_live_... key from your dashboard | | apiBaseUrl | string | https://api.docgenlab.com | Override for self-hosted / staging | | position | 'bottom-right' \| 'bottom-left' | 'bottom-right' | Launcher corner | | theme.primary | string | #4F46E5 | Accent color (header, send button, user msg) | | theme.primaryText | string | #FFFFFF | Text on top of the primary color | | theme.radius | string | 14px | Border radius for panel/bubble | | theme.fontFamily | string | system stack | Font family | | greeting | string | "Hi — how can I help?" | Empty-state message | | agentName | string | from /agent API | Override the displayed name | | agentAvatarUrl | string | none | Optional avatar shown next to assistant msgs | | enableImageUpload | boolean | true | Allow end-users to attach screenshots | | hideBranding | boolean | false | Hide "Powered by DocGenLab" — paid tier | | openOnLoad | boolean | false | Auto-open the panel on first load | | endUserId | string | — | Customer's authenticated user id. Conversations follow this user across browsers + devices (vs the default anonymous-per-browser cookie). Without endUserHash, the id is unverified. | | endUserHash | string | — | HMAC-SHA256 of endUserId signed with your identity-verification secret. Required only when the agent enforces identity verification. | | onReady | (agent) => void | — | Fired when the agent resolves | | onError | (err) => void | — | Fired on unrecoverable errors |

Identity verification (optional)

For unauthenticated visitors, the widget assigns an anonymous UUID per browser via localStorage. Conversations are scoped to that UUID.

If your site has authenticated users and you want chat history to follow each user across devices:

<DocGenLabChat
    agentKey="pk_live_..."
    endUserId={currentUser.id}
    endUserHash={currentUser.docgenlabHash}
/>

Generate endUserHash on YOUR backend (never on the client) using HMAC-SHA256:

import { createHmac } from 'crypto';
const hash = createHmac('sha256', process.env.DOCGENLAB_IDENTITY_SECRET)
    .update(user.id)
    .digest('hex');

Without endUserHash, the user id is unverified (any browser can claim any id). Standard Intercom-style trust model.

Responsive behaviour

The widget adapts automatically across breakpoints:

  • Phone portrait (≤480 wide): full-width bottom sheet, 90dvh tall (respects iOS Safari's collapsible bottom bar)
  • Phone landscape / short screens (≤600 high): side panel anchored to the launcher corner, doesn't fight the on-screen keyboard
  • Tablet (481–768 wide): slimmer 340px panel with reduced inset
  • Tiny phones (≤360 wide): smaller launcher (48px), tightened padding
  • Touch devices: larger tap-targets via @media (hover: none) and (pointer: coarse)

Browser support

ES2018+ targets. Edge, Chrome, Firefox, Safari (last 2 versions). IE11 not supported.

Bundle size

~50 KB gzipped (ESM, with React externalised). UMD bundle (React included) is ~95 KB gzipped.

Development

npm install
npm run dev      # Vite dev server
npm run build    # produces dist/index.js (ESM), dist/index.umd.cjs (UMD), dist/widget.css
npm run typecheck

License

UNLICENSED — internal DocGenLab project. Distribution to customers under separate commercial terms.