1.11.28 • Published 1 year ago

react-chat-engine v1.11.28

Weekly downloads
702
License
MIT
Repository
github
Last release
1 year ago

Chat Engine

Chat Engine is a free serverless chat API.

Try our free plan at chatengine.io

Installation

  • Using npm: npm install react-chat-engine --save
  • Using Yarn: yarn add react-chat-engine

Quick Start

Add serverless chat to your React app in 3 minutes.

  1. Register then create a project and user at chatengine.io

  2. Collect the public key, username and user password

  3. Install yarn add react-chat-engine

  4. Import the ChatEngine component and pass in publicKey, userName, and userSecret props

  5. Voila! You're done

EXAMPLE: Your implementation should look like the following

import React from 'react'

import { ChatEngine } from 'react-chat-engine'

export function App() {
  return (
    <ChatEngine
      publicKey={'b75e5bd5-cd84-404c-b820-06feff8c98c0'}
      userName={'john_smith'}
      userSecret={'secret_1234'}
    />
  )
}

Features

  • Authenticate users
  • Subscribe (connect) to incoming chats and messages
  • Create chats and messages
  • Add and remove people from chats
  • Edit and delete chat and message data

Props

  • publicKey (UUID REQUIRED) - Public API key for your chatengine.io project
  • userName (String REQUIRED) - Username of a person in this project
  • userSecret (String REQUIRED) - Set a secret for this person and use it to authenticate.
  • onConnect (Function) - Callback when the connection/authentication is complete
  • onFailAuth (Function) - Callback when the connection/authentication fails
  • onGetChats (Function) Callback when the person fetches their chats array
  • onNewChat (Function) - Callback when the person creates a new chat
  • onEditChat (Function) - Callback when the person edits a chat title
  • onDeleteChat (Function) - Callback when the person deletes one of their chats (must the chat's admin)
  • onAddPerson (Function) - Callback when a person is added to a chat
  • onRemovePerson (Function) - Callback when a person is removed/deleted from a chat
  • onGetMessages (Function) - Callback when the person gets a chat's messages
  • onNewMessage (Function) - Callback when a person posts a new message in one of the chats
  • onEditMessage (Function) - Callback when a person edits a new message in one of the chats
  • onDeleteMessage (Function) - Callback when a person deletes a new message in one of the chats
  • hideUI (Boolean) - Hides all UI components for a custom implementation (Warning: Advanced)

Functions

import { functionName } from 'react-chat-engine'

...

functionName(conn, args)
  • getChats (conn) => void - Get a person's array of chats
  • newChat (conn, title) => void - Create a new chat with this person as admin
  • editChat (conn, chatId, chatObj) => void - Edit the title of an existing chat
  • deleteChat (conn, chatId) => void - If you're admin, delete this existing chat
  • addPerson (props, chatId, userName) => void - Add an existing person (in the project) to an existing chat
  • removePerson (props, chatId, userName) => void - If you're admin, remove this user from an existing chat
  • getMessages (props, chatId) => void - Get the messages for an existing chat
  • sendMessage (props, chatId, messageObj) => void - Send a new message object into this chat
  • editMessage (props, chatId, messageId, messageObj) => void - Edit an exiting message object in this chat
  • deleteMessage (props, chatId, messageId) => void - Delete an exiting message object from this chat

Objects

Chat Object

  • id (int) - Unique primary key to identify this chat
  • admin (String) - Unique username of the person who created this chat
  • title (String) - Optional title of this chat
  • created (Datetime) - Date-time of chat creation
  • people (Array) - Array of people added to this chat
{
    "id": 1,
    "admin": "john_smith",
    "title": "Canada Day Party!",
    "created": "2020-09-05T20:28:22.352373Z",
    "people": [
        {
            "person": "john_smith"
        }
    ]
}

Chat / Person Association

  • person (String) - Unique username of a person involved in this chat
{ person: "john_smith" }

Message Object

  • id (int) - Unique primary key to identify this message
  • sender (String) - Unique username of the person who sent this message
  • text (String) - Contents of the message sent
  • created (Datetime) - Date-time of message creation
{
    "id": 1,
    "sender": "john_smith",
    "text": "Hey let's party!",
    "created": "2020-09-07T13:20:26.936400Z"
}
1.11.27

1 year ago

1.11.28

1 year ago

1.11.25

1 year ago

1.11.26

1 year ago

1.11.24

1 year ago

1.11.23

2 years ago

1.11.22

2 years ago

1.11.21

3 years ago

1.11.16

3 years ago

1.11.17

3 years ago

1.11.14

3 years ago

1.11.15

3 years ago

1.11.12

3 years ago

1.11.13

3 years ago

1.11.10

3 years ago

1.11.11

3 years ago

1.11.18

3 years ago

1.11.19

3 years ago

1.11.20

3 years ago

1.11.9

3 years ago

1.11.8

3 years ago

1.11.7

3 years ago

1.11.6

3 years ago

1.11.4

3 years ago

1.11.5

3 years ago

1.11.3

3 years ago

1.11.2

3 years ago

1.11.1

3 years ago

1.11.0

3 years ago

1.10.16

3 years ago

1.10.17

3 years ago

1.10.15

3 years ago

1.10.14

3 years ago

1.10.13

3 years ago

1.10.12

3 years ago

1.10.9

3 years ago

1.10.11

3 years ago

1.10.8

3 years ago

1.10.7

3 years ago

1.10.5

3 years ago

1.10.4

3 years ago

1.10.3

3 years ago

1.10.2

3 years ago

1.10.1

3 years ago

1.10.0

3 years ago

1.9.2

3 years ago

1.9.1

3 years ago

1.9.0

3 years ago

1.8.11

3 years ago

1.8.12

3 years ago

1.8.13

3 years ago

1.8.10

3 years ago

1.8.9

3 years ago

1.8.8

3 years ago

1.8.7

3 years ago

1.8.6

3 years ago

1.8.5

3 years ago

1.8.4

3 years ago

1.8.2

3 years ago

1.8.3

3 years ago

1.8.1

3 years ago

1.8.0

3 years ago

1.7.1

3 years ago

1.7.0

3 years ago

1.6.4

3 years ago

1.6.6

3 years ago

1.6.5

3 years ago

1.6.3

3 years ago

1.6.2

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.5.14

3 years ago

1.5.13

3 years ago

1.5.12

3 years ago

1.5.10

3 years ago

1.5.11

3 years ago

1.5.9

3 years ago

1.5.8

3 years ago

1.5.7

3 years ago

1.5.6

3 years ago

1.5.5

3 years ago

1.5.4

3 years ago

1.5.3

3 years ago

1.5.2

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.7

3 years ago

1.4.6

3 years ago

1.4.5

3 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.8

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.15

4 years ago

1.2.14

4 years ago

1.2.13

4 years ago

1.2.12

4 years ago

1.2.11

4 years ago

1.2.10

4 years ago

1.2.9

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago