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

docaider-embed

v0.3.9

Published

AI-powered embed chat widget for Docaider

Readme

Docaider Embed Widget

npm version License: MIT Website

The official AI-powered chat widget for Docaider. Seamlessly integrate a smart knowledge base assistant into your website with a few lines of code.

Compatible with HTML, React, Vue, and any other framework.

✨ Features

  • 🤖 AI-Powered: Instant answers from your knowledge base.
  • 🎨 Customizable: Control colors, position, and branding.
  • ⚛️ Framework Agnostic: First-class support for React and Vue.
  • 🛡️ Shadow DOM: Styles are isolated and won't conflict with your site.
  • 📱 Responsive: Optimized for desktop and mobile.
  • 🎮 Control API: Open, close, and interact programmatically.

🚀 Quick Start (HTML)

The fastest way to get started is using the pre-built script. Add this to your <body> tag:

<script 
  src="https://unpkg.com/docaider-embed/dist/embed.js"
  data-kb-id="YOUR_KNOWLEDGE_BASE_ID"
  data-title="AI Assistant"
  data-theme="blue"
  data-position="bottom-right">
</script>

That's it! The widget will appear on your site.


📦 Installation (NPM)

For React, Vue, or modern JavaScript applications:

npm install docaider-embed
# or
yarn add docaider-embed
# or
pnpm add docaider-embed

⚛️ React Usage

Import the component and use it in your app. Styles are injected automatically.

import { useRef } from "react";
import { EmbedChatBox, type EmbedChatBoxRef } from "docaider-embed";

function App() {
  const chatRef = useRef<EmbedChatBoxRef>(null);

  return (
    <>
      <button onClick={() => chatRef.current?.open()}>
        Open Chat
      </button>

      <EmbedChatBox 
        ref={chatRef}
        knowledgeBaseId="YOUR_KNOWLEDGE_BASE_ID"
        // Optional: Override the default API endpoint
        src="https://your-docaider-instance.com" 
        theme="blue"
        position="bottom-right"
      />
    </>
  );
}

🟢 Vue Usage

We provide a dedicated Vue plugin and composable for the best developer experience.

1. Global Registration (Recommended)

Register the plugin in your main.ts:

import { createApp } from "vue";
import App from "./App.vue";
import { DocaiderEmbed } from "docaider-embed/vue";

const app = createApp(App);
app.use(DocaiderEmbed);
app.mount("#app");

Then use the component anywhere:

<template>
  <VueEmbedChatBox
    knowledgeBaseId="YOUR_KNOWLEDGE_BASE_ID"
    theme="green"
  />
</template>

2. Programmatic Control (Composable)

Control the widget from any component (even without a ref) using useDocaiderEmbed:

<script setup lang="ts">
import { useDocaiderEmbed } from "docaider-embed/vue";

// Control the global chat instance
const { 
  open, 
  close, 
  toggle, 
  setWelcomeMessage, 
  setMessage,
  sendMessage,
  useTool,
  useKnowledge 
} = useDocaiderEmbed();

const openSupport = () => {
  setWelcomeMessage("Hi! How can I help you with billing today?");
  open();
};

const closeChat = () => {
  close();
};

const toggleChat = () => {
  toggle();
};

const prefillInput = () => {
  setMessage("I have a question about...");
  open();
};

const autoSendMessage = () => {
  sendMessage("What are your business hours?");
};

const correctGrammar = () => {
  useTool("context", { 
    prompt: "Correct Grammar", 
    content: "I go to schol today" 
  });
  open();
};

const injectContext = () => {
  // Inject custom data for the AI to use
  useKnowledge("User Profile", { 
    name: "John Doe", 
    plan: "Premium" 
  });
  
  // Or clear context
  // useKnowledge(null);
};
</script>

<template>
  <div class="buttons">
    <button @click="openSupport">Open Support</button>
    <button @click="closeChat">Close</button>
    <button @click="toggleChat">Toggle</button>
    <button @click="prefillInput">Prefill Input</button>
    <button @click="autoSendMessage">Ask Question</button>
    <button @click="correctGrammar">Fix Grammar</button>
    <button @click="injectContext">Inject Data</button>
  </div>
</template>

📚 API Reference

Props / Attributes

| Prop (React/Vue) | Attribute (HTML) | Type | Default | Description | |------------------|------------------|------|---------|-------------| | knowledgeBaseId | data-kb-id | string | Required | Your Docaider Knowledge Base ID | | src | src | string | undefined | Custom Docaider instance URL (if self-hosted) | | chatId | data-chat-id | string | undefined | Unique identifier for the chat session | | chatboxTitle | data-title | string | "AI Assistant" | Title displayed in the header | | position | data-position | string | "bottom-right" | bottom-right, bottom-left, top-right, top-left | | theme | data-theme | string | "blue" | blue, gray, green, orange, purple | | welcomeMessage | data-welcome-message | string | "Hello..." | Initial message bubble text | | placeholder | data-placeholder | string | "Ask a question..." | Input field placeholder | | width | data-width | string | "350px" | Width of the chat window | | height | data-height | string | "500px" | Height of the chat window | | logo | data-logo | string | undefined | URL to a custom logo image | | documents | data-documents | { title: string }[] | [] | List of available documents to show in file list | | onRefresh | - | () => void | undefined | Callback when refresh button is clicked | | positionStrategy | data-position-strategy | "fixed" \| "absolute" | "fixed" | Positioning strategy for the chat window | | initialSuggestions | data-initial-suggestions | string[] | [] | Initial quick suggestions to display |

Instance Methods

Methods available on the ref (React/Vue) or window.Docaider (HTML):

  • open(): Opens the chat window.
  • close(): Closes the chat window.
  • toggle(): Toggles the open/closed state.
  • setWelcomeMessage(msg: string): Updates the welcome message bubble immediately.
  • setMessage(msg: string): Sets the text in the input field.
  • sendMessage(msg: string): Programmatically sends a message as the user.
  • useTool(tool: string, options?: { content?: string; prompt?: string }): Programmatically triggers a specific tool or action.
    • tool: "context" | "readCurrentPage" | "knowledge-base" | "auto" | "askQuestion"
    • options: Optional parameters for the tool (e.g., { prompt: "Correct Grammar", content: "Text to correct" })
  • useKnowledge(nameOrContext: string | any, content?: any): Programmatically sets or clears knowledge context.
    • Set Default Context: useKnowledge({ foo: "bar" })
    • Set Named Context: useKnowledge("My Context", { foo: "bar" })
    • Clear Context: useKnowledge(null) or useKnowledge("My Context", null)

🔗 Links


License

MIT © Docaider