Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

@chatlychat/widget-react

Latest version: v0.28.0

Overview

Last scanned
26 Nov 2026
Published
26 Nov 2026
npm package Publisher: thinklikeajew
0 Stars
0 Forks
35 Versions
3.5K Downloads
TypeScript Repo language

Scan summary

@chatlychat/widget-react was last scanned on 26 Nov 2026 at version 0.28.0. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 35 versions; the latest was published on 26 Nov 2026.
  • Findings: No rules fired in version 0.28.0.
  • Downloads: 3,475 downloads.

Versions

35 versions published
Versions and the rules that fired in each
VersionPublishedStatus
0.28.0 LATEST 26 Nov 2026 No rules fired
0.27.1 19 Nov 2026 No rules fired
0.27.0 19 Nov 2026 No rules fired
0.26.0 17 Nov 2026 Not shown
0.25.1 4 Nov 2026 Not shown

No rules fired in 0.28.0

Findings

Findings for v0.28.0. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 0.28.0; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

@chatlychat/widget-react

The Chatly chat widget as a React component.

pnpm add @chatlychat/widget-react
import { ChatlyWidget, useChatly } from '@chatlychat/widget-react';

export function App() {
  return (
    <>
      {/* One of these, high in the tree. */}
      <ChatlyWidget publicId="acme-web" visitor={{ externalId: user.id, email: user.email }} />
      <Routes />
    </>
  );
}

export function HelpButton() {
  const chatly = useChatly();
  return <button onClick={() => chatly.open('help')}>Help</button>;
}

That is the whole integration. No <script> tag, no window.Chatly, no effect of your own — the component injects the loader, mounts the widget and tears it down when it unmounts.

Why this exists

Without it, the integration is an effect you write by hand:

// Don't. This is the version that was in our own docs, and it has three bugs.
useEffect(() => {
  window.Chatly?.init({ publicId });
  return () => window.Chatly?.destroy();
}, [publicId]);
  1. It boots twice in StrictMode. React 18 runs every effect mount → cleanup → mount in development, so that is init → destroy → init: two visitor sessions minted, and a launcher that visibly flickers.
  2. A theme in the deps re-initialises on every render. theme={{…}} is a new object each time, so the widget is destroyed and rebuilt underneath a visitor who was mid-sentence.
  3. It can never identify anybody. The only place to put an identity is init, which has already run by the time your user signs in.

This component fixes all three, and the mechanism is shared with the custom element in @chatlychat/widget-element so the two cannot drift on the part that is hard.

React is a peer dependency

react is in peerDependencies, never dependencies, and that is a deliberate exception to this repo's "no new dependencies" rule.

A real dependency resolves a second copy of React in any consumer whose version differs by so much as a patch, and two Reacts on one page break hooks with Invalid hook call — thrown from a component the consumer did not write and cannot debug. A peer dependency on the framework the consumer is already using adds nothing to their install and cannot duplicate.

The range is ^18.0.0 || ^19.0.0. The component uses useRef and useEffect and nothing newer, so it works on both.

Everything else here has one dependency, @chatlychat/widget-element, which itself has none.

<ChatlyWidget />

Every init option is a prop: publicId (required), apiUrl, realtimeUrl, visitor, theme, behavior, quickLinks, copy, copyByLocale, cssOverrides.

Plus five of its own:

prop type
loaderUrl Where loader.js is served from. Rarely set; see below.
locale Calls setLocale() once the widget is up.
nonce Your page's CSP nonce, if you serve one; see below.
inline Render the chat inside this component's own box.
className / style Applied to the inline container.

And all twelve of the events, as callbacks: onReady, onOpen, onClose, onMessage, onMessageAck, onMessageReceived, onUnread, onConversation, onIdentified, onReset, onAction, onError. Pass inline arrow functions freely — they are read through a ref, so a new one on every render costs nothing and the handler that fires is always the latest.

onMessage means "the visitor sent something" and has never fired for a reply. onMessageReceived is an agent or bot message that arrived while its thread was on screen, and onUnread is the badge number — fired as soon as it is known and on every change.

What a prop change actually does

This is the part worth knowing, because the three outcomes are different:

changed prop what happens
visitor identify(). Nothing is re-mounted.
visitor → undefined reset() — a sign-out, so the next session is fresh.
visitor={null} reset() on mount too, not only on a change.
locale setLocale(). Nothing is re-mounted.
anything else init() again, which destroys and re-mounts.

A re-mount loses nothing durable — the conversation lives on the server — but it closes an open panel. What this component guarantees is that it only happens when a value really changed, not when a parent re-rendered.

visitor={null} — signing out on a page that loaded signed out

The two visitor rows above are transitions: the prop held an identity and then went away. A page that renders already signed out never makes that transition, so the previous account's external id stays in the browser — the widget keeps it at chatly:xid:<publicId> so it can spot an account switch. On a shared device that is the last person's identity outliving a sign-out that happened in another tab.

Pass null and the widget compares its own stored identity on mount and resets itself if one is there. You need no localStorage key of your own for it:

// signed out, and saying so
<ChatlyWidget publicId="acme-web" visitor={user ? { externalId: user.id, userHash } : null} />

An absent visitor still changes nothing, deliberately. The widget cannot tell it apart from "identity has not resolved yet", and a reset on that would drop a live conversation every time your auth check is slow — so visitor={user ? {…} : undefined} keeps today's behaviour. null is the opt-in. It is also ignored when identity or identityEndpoint is set, since a provider answers the same question under the same rule.

A changed theme value is applied live with setTheme() — an open panel is repainted in place, with no re-mount and no network request — so computing the theme from your light/dark state is safe. The prop re-initialises only when a top-level key is REMOVED (or set to undefined), because a merge cannot un-apply one; a value changed live and then removed keeps its last value until a page load.

loaderUrl is the exception: changing it after load warns and does nothing, because the bundle is already fetched and pointing the running widget at another deployment would need a page reload.

nonce — a page served with a strict CSP

If your app is served script-src 'nonce-…' with no 'unsafe-inline', pass that response's nonce:

// Next.js App Router: the nonce your middleware minted for THIS response
import { headers } from 'next/headers';

export default async function Layout() {
  const nonce = (await headers()).get('x-nonce') ?? undefined;
  return <ChatlyWidget publicId="acme-web" nonce={nonce} />;
}

It goes on the loader.js script the component injects, and onto window.Chatly.nonce so that widget.js, the deferred chunks and the panel's own stylesheet carry it too. Without it a nonce-only policy blocks the loader, and the only sign is a CSP violation in your console.

nonce also works on <ChatlyLauncher publicId>, which is the other component that injects the loader.

Mint a fresh value per response and never hardcode one. A nonce that repeats is no better than 'unsafe-inline': anyone who can read one page's source can inject a script the next page will run. This component caches nothing — but a framework will happily cache the HTML you put it in, so the value has to come from the request. It is read once, before the loader is injected; changing it in props afterwards warns rather than re-stamping a script the browser has already evaluated.

If your policy allows the widget's origin by host instead, leave the prop off. Nothing is stamped and the embed injects exactly what it always has.

Inline mounting
<ChatlyWidget publicId="acme-web" inline className="h-[600px] w-full rounded-lg border" />

The chat fills the box instead of floating in the corner — a support page, a sidebar, a full-page /chat route. In this mode there is no launcher, no corner offset, and close() warns instead of working (hide or unmount your own container instead).

This is the React shape of the widget's mountTo option, and it closes mountTo's one sharp edge: the container must exist when init runs, and a selector that matches nothing makes the widget refuse to mount at all. A container this component renders itself cannot be missing.

Give it a height. It has a 420px minimum so a container with none is still usable.

useChatly()

Returns the widget's post-boot methods: open, close, toggle, identify, setUser, setCustomAttributes, deleteCustomAttribute, setLabel, removeLabel, setLocale, track, registerPushToken, reset, dismiss, setStorageConsent, setConsent, setOffset, setTheme, getUnreadCount, hasSession, startConversation, setContext, reportAction — plus load.

load() is the one method that is not the widget's: it is the loader's, and it starts the bundle download without opening anything (what lazy="manual" needs, and what a hover-prefetch on your own button does). It is here so you never have to reach for window.Chatly. It is a no-op once the bundle is up.

The object is referentially stable, so it is safe in a dependency array.

init and destroy are deliberately not on it. The component owns the lifecycle; calling them behind its back leaves it believing a widget is mounted that is not, after which the next unmount does nothing and the next mount does nothing.

Every method returns void, including identify, which the widget's own API returns a promise from. Your call may be queued before the bundle has arrived and there is nothing to await in that state — use onIdentified (or useChatlyEvent('identified', …)) to learn that it landed, and onError to learn that it did not.

Calling any of them before a widget has mounted is safe, and since 0.19.0 the call is not lost either: it is queued and replayed as soon as one mounts. A "Chat with us" link in your header keeps its first click even when <ChatlyWidget> renders a commit later, or after a channel id has been fetched. One console warning says the call was queued, because a page that never mounts a widget still gets nothing. It never throws: a misconfigured chat must not break your click handler.

useChatlyEvent(event, handler)

function ChatAnalytics() {
  useChatlyEvent('open', () => analytics.track('chat_opened'));
  // The detail is `unknown` here. For the typed payload, use the component's
  // own `onMessage={(m) => …}` — see `<ChatlyWidget />` above.
  useChatlyEvent('message', () => analytics.track('visitor_sent_message'));
  return null;
}

Subscribes for the life of the component. The handler is read through a ref, so an inline arrow does not re-subscribe on every render.

'ready' fires immediately if the session is already up — the widget replays the last one — which is what makes this usable from a component that mounts long after the page did.

What 'message' is, and is not

'message' fires when the VISITOR sends something. An agent's reply does not fire it, and neither does a bot's. It is the hook for "this person started talking to us" — analytics, a form you want to stop showing, a Slack ping — and it is the wrong hook for anything about incoming mail.

This README showed an UnreadBadge built on it, which never counted a single reply. It counted the visitor's own messages, and the bug was invisible because the number went up when you tested it by typing.

An unread badge

There is an unread event, and it is what a badge should use. It carries { count } and it is replayed to a late subscriber, so a component that mounts a minute after the page did still gets the current number:

import { useState } from 'react';
import { useChatly, useChatlyEvent } from '@chatlychat/widget-react';

function UnreadBadge() {
  const chatly = useChatly();
  // `getUnreadCount()` is the same number, for the first paint — before any
  // change has happened there is no event to have heard.
  const [unread, setUnread] = useState(() => chatly.getUnreadCount());
  useChatlyEvent('unread', (detail) => setUnread((detail as { count: number }).count));

  return unread > 0 ? <span className="badge">{unread}</span> : null;
}

No request of your own, no second visitor session to reconcile, and nothing to install beyond this package. The widget refreshes the number at boot, when the tab comes back, when the panel closes, and on a 60-second poll while the visitor has an open or pending thread they are not looking at — and it spends nothing at all on a visitor who has never had a conversation.

The count is agent and bot messages the visitor has not had on screen, across their threads. It is derived from the widget's own watermark rather than the server's unreadContactCount, and the difference matters: nothing zeroes that column for a visitor, it counts an agent's private notes, and it does not count bot replies — the most common reply in this product.

This README used to deny that the event existed, and showed a badge built on @chatlychat/sdk-js's client.unreadCount(). That call still exists and is still right for a page that renders no widget at all, but it is a different number from the one above, and it kept its own visitor session under its own storage key — so for an anonymous visitor the two were two different contacts and the count was not about the conversations in the panel. Do not mix them in one badge.

useChatlyEvent and the props reach the same twelve events

They did not until 2026-10-16: unread, message.ack and message.received had no onX prop and no chatly-* DOM event, on the reasoning that "a dotted name does not survive the rename and a replayed event cannot be a DOM event". Neither held. A dot becomes a dash, which is what this package already does to every option name that crosses into HTML, and ready was always both replayed and a DOM event. All twelve now have a prop, a DOM event and a useChatlyEvent name.

useChatlyEvent and subscribe() still go through Chatly.on directly, and that is the route to prefer for a badge: a replayed event (ready, unread) fires at the moment you subscribe, so a hook that mounts long after the page did is told the current count rather than nothing.

<ChatlyLauncher /> — your button, the bundle loaded on demand

import { ChatlyLauncher } from '@chatlychat/widget-react';

// Owner: nothing else mounts the widget, and `widget.js` (~44KB gzipped) is
// not fetched until somebody uses this button.
<ChatlyLauncher publicId="acme-web" className="btn btn-primary">
  Chat with us
</ChatlyLauncher>;

// Control: a page that already renders <ChatlyWidget />. Claims nothing;
// clicking it is `useChatly().open()`.
<ChatlyLauncher openTab="help">Help</ChatlyLauncher>;

Whether it owns the widget is decided by one thing: a publicId. With one it claims the widget with lazy: 'launcher' and theme.hideLauncher, and since 0.18.0 nothing is fetched at all until the visitor reaches for the chat — not the bundle and not loader.js either. The first hover, focus or click downloads both and opens the panel; hovering or focusing starts it early, so the click usually finds it cached. Pass prefetchOnHover={false} to make the fetch strictly click-triggered.

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm @chatlychat/widget-react

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Vulnerability Insights

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?

Microsoft's Official agent framework Hijacked
AI & VibeSec

BREAKING: Hijacked Releases of Microsoft’s Official agent-framework Steals Azure and CI Credentials

Vulnerability Insights

Compromised Claude Code extensions (versions 2.1.312 & 2.1.313) in Cursor try to install a backdoor

Frame 2085668439 (1)
Group 1261154229