← Back to Docs

React ChatButton (Public Mode)

Using React components for floating chat button widget

You're viewing a React demo page

The chat button is rendered using React. Look for the chat button in the bottom-right corner!

Installation

npm install react react-dom @diegoaltoworks/chatter
# or
bun add react react-dom @diegoaltoworks/chatter

Basic React Usage

Import and use the ChatButton component in your React app:

import React from 'react';
import { ChatButton } from '@diegoaltoworks/chatter/client';
import '@diegoaltoworks/chatter/client/style.css';

function App() {
  return (
    <ChatButton
      host="your-api-url.com"
      mode="public"
      apiKey="YOUR_API_KEY_HERE"
      position="bottom-right"
      label="💬"
      chatConfig={{
        title: 'Chat with us',
        subtitle: 'We typically reply in a few minutes'
      }}
    />
  );
}

With TypeScript

import React from 'react';
import { ChatButton, ChatButtonConfig } from '@diegoaltoworks/chatter/client';
import '@diegoaltoworks/chatter/client/style.css';

const config: ChatButtonConfig = {
  host: 'your-api-url.com',
  mode: 'public',
  apiKey: 'YOUR_API_KEY_HERE',
  position: 'bottom-right',
  label: '💬',
  chatConfig: {
    title: 'Chat with us',
    subtitle: 'We typically reply in a few minutes'
  }
};

function App() {
  return <ChatButton {...config} />;
}

How This Demo Works

This page uses React with the ChatButton component:

import React from 'react';
import { ChatButton } from '@diegoaltoworks/chatter';
import '@diegoaltoworks/chatter/style.css';

function App() {
  return (
    <ChatButton
      host="your-api-url.com"
      mode="public"
      apiKey="YOUR_API_KEY_HERE"
      position="bottom-right"
      label="💬"
      chatConfig={{
        title: 'Public Chat',
        subtitle: 'We are here to help'
      }}
    />
  );
}

Configuration Options

Try it now!

Click the chat button in the bottom-right corner to start chatting. This button was rendered using React!