1.1.10 • Published 4 months ago

react-chat-widget-2 v1.1.10

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

React Chat Widget 2 (fork)

Features

  • Plain text message UI
  • Snippet style for links (only as responses for now)
  • Fully customizable
  • Easy to use

Installation

npm

npm install --save react-chat-widget-2

yarn

yarn add react-chat-widget-2

Usage

1- Add the Widget component to your root component

import React from "react";
import { Widget } from "react-chat-widget-2";

import "react-chat-widget-2/lib/styles.css";

function App() {
  return (
    <div className="App">
      <Widget />
    </div>
  );
}

export default App;

2- The only required prop you need to use is the handleNewUserMessage, which will receive the input from the user.

import React from "react";
import { Widget } from "react-chat-widget-2";

import "react-chat-widget-2/lib/styles.css";

function App() {
  const handleNewUserMessage = (newMessage) => {
    console.log(`New message incoming! ${newMessage}`);
    // Now send the message throught the backend API
  };

  return (
    <div className="App">
      <Widget handleNewUserMessage={handleNewUserMessage} />
    </div>
  );
}

export default App;

3- Import the methods for you to add messages in the Widget. (See messages)

import React from "react";
import { Widget, addResponseMessage } from "react-chat-widget-2";

import "react-chat-widget-2/lib/styles.css";

function App() {
  useEffect(() => {
    addResponseMessage("Welcome to this awesome chat!");
  }, []);

  const handleNewUserMessage = (newMessage) => {
    console.log(`New message incoming! ${newMessage}`);
    // Now send the message throught the backend API
    addResponseMessage(response);
  };

  return (
    <div className="App">
      <Widget handleNewUserMessage={handleNewUserMessage} />
    </div>
  );
}

export default App;

4- Customize the widget to match your app design! You can add both props to manage the title of the widget and the avatar it will use. Of course, feel free to change the styles the widget will have in the CSS

import React from 'react';
import { Widget, addResponseMessage, addLinkSnippet, addUserMessage } from 'react-chat-widget-2';

import 'react-chat-widget-2/lib/styles.css';

import logo from './logo.svg';

function App() {
  useEffect(() => {
    addResponseMessage('Welcome to this awesome chat!');
  }, []);

  const handleNewUserMessage = (newMessage) => {
    console.log(`New message incoming! ${newMessage}`);
    // Now send the message throught the backend API
  };

  render() {
    return (
      <div className="App">
        <Widget
          handleNewUserMessage={handleNewUserMessage}
          profileAvatar={logo}
          title="My new awesome title"
          subtitle="And my cool subtitle"
        />
      </div>
    );
  }
}

export default App;
1.1.10

4 months ago

1.0.33

6 months ago

1.0.32

7 months ago

1.0.37

6 months ago

1.0.36

6 months ago

1.0.35

6 months ago

1.0.34

6 months ago

1.1.1

6 months ago

1.1.0

6 months ago

1.0.39

6 months ago

1.0.38

6 months ago

1.1.9

5 months ago

1.1.8

6 months ago

1.1.7

6 months ago

1.1.6

6 months ago

1.1.5

6 months ago

1.1.4

6 months ago

1.1.3

6 months ago

1.1.2

6 months ago

1.0.29

11 months ago

1.0.31

11 months ago

1.0.30

11 months ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.9

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.12

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

3.0.3

3 years ago