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

@opencx/widget-react-headless

v5.14.1

Published

Headless React helpers and hooks.

Readme

OpenCX Widget - React Headless

Headless React helpers and hooks.

For more information, check the documentation

Selectable questions

A custom client must render question choices, collect selections or free text, and submit the answer before declaring support:

<WidgetProvider
  components={yourComponents}
  options={{
    token: 'YOUR_WIDGET_TOKEN',
    capabilities: { structuredQuestions: true },
  }}
>
  <YourChat />
</WidgetProvider>

Omitting this capability leaves the structured question tool unavailable. Ordinary text questions remain available. The organization must also enable Selectable questions. The built-in Widget declares support automatically for its default question component. If you replace agent_chat_questions, explicitly declare support after implementing the replacement.

Delivery, activity and renderer support

These options are included in the next beta after 5.0.0-beta.1:

<WidgetProvider
  components={yourComponents}
  options={{
    token: '<WIDGET_TOKEN>',
    streaming: false,
    presentation: { toolActivity: 'hidden', reasoning: false },
  }}
>
  <YourChat />
</WidgetProvider>

streaming defaults to false, preserving v4 polling without changing the server's agent version. Set streaming: true to opt into streaming when the backend supports it. Personal service connections also require capabilities.connections: true. The organization controls maximum activity visibility. An embed may narrow toolActivity to status (name and status without inputs/results) or hidden, and disable reasoning. It cannot override an organization restriction. Tools still execute when their activity is hidden. The backend applies the same limits to live replies, reconnects and history; the default is status-only activity and hidden reasoning.

A headless client does not declare renderer support automatically. Set capabilities.structuredQuestions, capabilities.richReplies, or capabilities.pageEffects to true only after implementing that interaction. These capabilities also require the organization's feature and streaming; polling receives completed replies without structured interactions. Ordinary clarifying questions in text do not require a selectable-question renderer. Interactive question and highlight payloads remain available when activity is hidden because they drive the customer-facing UI.

Changing options on an existing provider updates subsequent requests without resetting its session. A delivery change waits for accepted messages, queued messages and reply reconciliation to finish on their current transport. Streaming reconnects and history fetches include the current presentation opt-outs. Changing visibility refreshes existing history; useAgentChatUi() immediately hides opted-out activity in both live and cached turns, including while that refresh is pending or fails. Integrations keeping a separate cache can use applyPresentation(items, presentation) to apply the same display rules.

React Native

Streaming in React Native needs Expo SDK 52 or later and three things from the app:

import { fetch as expoFetch } from 'expo/fetch';

<WidgetProvider
  components={yourComponents}
  options={{
    token: '<WIDGET_TOKEN>',
    streaming: true,
    streamingFetch: expoFetch as typeof fetch,
  }}
>
  <YourChat />
</WidgetProvider>;
  1. streamingFetch: React Native's built-in fetch cannot read a response while it arrives. Expo SDK 57 installs expo/fetch as the global fetch (unless EXPO_PUBLIC_USE_RN_FETCH is set), so there streamingFetch can be left out. Every other request keeps using the global fetch. If you wrap expoFetch (to add headers or logging), return its response unchanged. React Native's global Response has no readable body, so the widget cannot read a response rebuilt with new Response(...). It then reads the reply again through the global fetch and logs a warning once; where the global fetch cannot stream either, the reply appears once it is saved.
  2. Globals: the widget needs crypto.getRandomValues, which React Native does not provide. Install react-native-get-random-values and import it first in your entry file. The stream reader also uses structuredClone and TextDecoderStream; Expo SDK 57 has both, and older runtimes need polyfills installed at startup, before the widget is imported.
  3. Resuming a dropped reply: browsers resume when the tab is visible again or the network returns. React Native has neither event, so call useAgentChatUi().resumeInterruptedTurn() when AppState becomes active and when connectivity returns. It does nothing unless the last reply was cut off.