@zynli/react-widget
v0.1.1
Published
Embed the Zynli support chat widget in React and Next.js apps
Maintainers
Readme
@zynli/react-widget
Embed the Zynli support chat widget in React and Next.js apps.
This package loads the same embed.js used by vanilla HTML integrations (hazeljs-support-chat).
Install
npm install @zynli/react-widgetPeer dependencies: react, react-dom. For Next.js, install next (optional peer).
Monorepo / local development:
"@zynli/react-widget": "file:../zynli/zynli-react-widget"Run npm run build inside zynli-react-widget after changes.
Next.js (App Router)
// app/layout.tsx or a client wrapper
import { ZynliWidgetNext } from "@zynli/react-widget/next";
export default function RootLayout({ children }) {
return (
<html>
<body>
{children}
<ZynliWidgetNext
tenant={process.env.NEXT_PUBLIC_ZYNLI_TENANT!}
scriptUrl={process.env.NEXT_PUBLIC_ZYNLI_EMBED_SCRIPT_URL}
appUrl={process.env.NEXT_PUBLIC_ZYNLI_APP_URL}
/>
</body>
</html>
);
}NEXT_PUBLIC_ZYNLI_TENANT=your_tenant_id
NEXT_PUBLIC_ZYNLI_EMBED_SCRIPT_URL=https://hazeljs.zynli.ai/embed.js
NEXT_PUBLIC_ZYNLI_APP_URL=https://hazeljs.zynli.aiReact (Vite, CRA, etc.)
import { ZynliWidget } from "@zynli/react-widget";
export function App() {
return (
<>
<main>...</main>
<ZynliWidget
tenant="your_tenant_id"
appUrl="https://hazeljs.zynli.ai"
/>
</>
);
}Props
| Prop | Required | Description |
|------|----------|-------------|
| tenant | Yes | Workspace tenant id from Zynli |
| scriptUrl | No* | Full URL to embed.js |
| appUrl | No* | App origin; used as {appUrl}/embed.js if scriptUrl omitted |
| offset | No | "default" (16px margin) or "0" (flush to corner) |
| enabled | No | false to skip rendering (default: true when tenant is set) |
* Provide at least one of scriptUrl or appUrl.
Vanilla HTML
You do not need this package for plain HTML — use embed.js directly. See hazeljs-support-chat/WIDGET_EMBED.md.
/widget preview (support-chat)
Opening /widget without embedOrigin (e.g. http://localhost:3001/widget?tenant=…) uses this package to load embed.js, matching production host sites. The iframe loads /widget?embedOrigin=… with the live chat UI (markdown answers, doc citations, etc.).
