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

tomai-chatbox-widget

v1.0.5

Published

TomAI Chatbox widget: importable library and CDN embed

Readme

tomai-chatbox-widget

TomAI Chatbox widget – usable two ways:

  • Developer import (npm): programmatically mount into your app.
  • CDN embed (script tag): drop-in for any webpage.

Install (npm)

npm i tomai-chatbox-widget
# or
pnpm add tomai-chatbox-widget

Quick Start (Developer Import)

import { initTomaiChatbox } from 'tomai-chatbox-widget'

initTomaiChatbox({
  client_id: 'dd650ef8-45e6-4a66-a24f-8752f21f4577',
  mode: 'bubble', // 'bubble' | 'fullscreen' | 'popup'
  draggable: true
})

// Controls exposed globally for convenience
window.tomaiConfig.open()
window.tomaiConfig.close()
window.tomaiConfig.onToggleModal()
window.tomaiConfig.onFocusMessage()

CDN Embed (Script Tag)

<script>
  window.tomaiConfig = {
    client_id: 'dd650ef8-45e6-4a66-a24f-8752f21f4577',
    draggable: true,
    // mode: 'bubble' | 'fullscreen' | 'popup'
  }
</script>
<script id="chatbox" src="https://aichatbot.softworld.dev/plugins-temp/chatbox-script.js"></script>

Next.js (App Router) Example

Use a client-only initializer to mount the widget and avoid SSR:

// app/_components/TomaiChatboxClient.tsx
'use client'

import { useEffect } from 'react'
import { initTomaiChatbox, destroyTomaiChatbox } from 'tomai-chatbox-widget'

export default function TomaiChatboxClient() {
  useEffect(() => {
    // Guard to avoid double init in dev Strict Mode
    if (document.getElementById('sw-customer-chatbox')) return

    initTomaiChatbox({
      client_id: 'dd650ef8-45e6-4a66-a24f-8752f21f4577',
      draggable: true,
      mode: 'bubble' // 'bubble' | 'fullscreen' | 'popup'
    })

    return () => {
      destroyTomaiChatbox()
    }
  }, [])

  return null
}

Insert the client component at the end of your layout body:

// app/layout.tsx
import dynamic from 'next/dynamic'

const TomaiChatboxClient = dynamic(
  () => import('./_components/TomaiChatboxClient'),
  { ssr: false }
)

export default async function RootLayout({ children }) {
  return (
    <html>
      <head>{/* ... */}</head>
      <body>
        {children}
        <TomaiChatboxClient />
      </body>
    </html>
  )
}

Control the widget anywhere in client components:

window.tomaiConfig.open()
window.tomaiConfig.close()
window.tomaiConfig.onToggleModal()
window.tomaiConfig.onFocusMessage()

Config Options

  • client_id: required – your bot key.
  • mode: optional – 'bubble' (default), 'fullscreen', 'popup'.
  • draggable: optional – enable dragging of the launcher bubble.

Notes

  • The widget renders inside a Shadow DOM to avoid CSS conflicts.
  • It fetches appearance & initial message from the TomAI API based on client_id.
  • React is a peer dependency in npm usage; it’s not bundled.

Build & Publish

# Build the library (ES/UMD) and types
pnpm run build:lib
pnpm run build:types

# Optional: build the CDN IIFE script (chatbox-script.js)
pnpm run build:cdn

# Publish to npm (public scope)

npm publish --access public

Branding & Links

  • Website: https://tomai.vn
  • Repository: https://github.com/softworldvn/tomai-chatbox
  • Issues: https://github.com/softworldvn/tomai-chatbox/issues

License

MIT © SoftWorld