Socket
Book a DemoInstallSign in
Socket

@yext/chat-headless-react

Package Overview
Dependencies
Maintainers
84
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yext/chat-headless-react

the official React UI Bindings layer for Chat Headless

latest
Source
npmnpm
Version
0.9.5
Version published
Maintainers
84
Created
Source

Chat Headless React

Chat Headless React is the official React UI Bindings layer for Chat Headless

Full Documentation

Getting Started - ChatHeadlessProvider

Chat Headless React includes an <ChatHeadlessProvider /> component, which takes in a ChatConfig, instantiate a ChatHeadless instance and makes it available to the rest of your app:

import { ChatHeadlessProvider, ChatConfig } from "@yext/chat-headless-react";

const config: ChatConfig = {
  botId: "BOT_ID",
  apiKey: "API_KEY",
};

function MyApp() {
  return (
    <ChatHeadlessProvider config={config}>
      {/* Add components that use Chat as children */}
      <MyComponent />
    </ChatHeadlessProvider>
  );
}

Respond to State Updates with useChatState

useChatState reads a value from the ChatState state and subscribes to updates.

import { useChatState } from "@yext/chat-headless-react";

export default function MyComponent() {
  const isLoadingStatus = useChatState((state) => state.conversation.isLoading);
  return <div>{`Loading Status: ${isLoadingStatus}`}</div>;
}

Dispatch Actions with useChatActions

useChatActions allows you to dispatch actions using the ChatHeadless instance.

import { useChatActions } from "@yext/chat-headless-react";
import { useCallback } from "react";

function MyComponent() {
  const actions = useChatActions();
  const onClick = useCallback(() => {
    actions.setChatLoadingStatus(true);
  }, [actions]);

  return <button onClick={onClick}>Click Me</button>;
}

Keywords

chat

FAQs

Package last updated on 14 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts