ghostchat
v0.1.0
Published
Loader for the GhostChat live chat widget (~15KB gzipped). Injects the official embed script for your site.
Maintainers
Readme
ghostchat
Loader for the GhostChat live chat widget — a fast, privacy-friendly chat widget (~15KB gzipped).
This package is a thin wrapper around the official embed script. If you can paste a script tag, you don't need it:
<script src="https://api.ghostchat.dev/widget.js" data-site="YOUR_SITE_ID"></script>Use the package when you'd rather load the widget from JavaScript — e.g. in a React/Vue/Svelte app where you don't control the HTML template.
Install
npm install ghostchatUsage
import { init, on } from 'ghostchat';
init('YOUR_SITE_ID'); // site ID from app.ghostchat.dev → Setup
// Optional: hook widget events into your analytics
on('open', () => {});
on('close', () => {});
on('message', () => {});init() is a no-op during server-side rendering and when the widget is already on the page, so it's safe to call from a client component or a route that renders more than once. Handlers registered with on() before the widget finishes loading are buffered and attached once it's ready.
In React, call it from an effect:
useEffect(() => { init('YOUR_SITE_ID'); }, []);Docs
Full documentation: ghostchat.dev/developers
