@cyxth/chat
TypeScript icon, indicating that this package has built-in type declarations

0.0.8-beta.0 • Public • Published

cyxth chat api

Easily add fast and scalable chat functionality to your application with cyxth chat api.

install the packages

#  core
npm install @cyxth/core

#  chat
npm install @cyxth/chat

initialize cyxth chat

import Cyxth from '@cyxth/core';
import Chat from '@cyxth/chat';

// initialize cyxth
const cyxth = new Cyxth("YOUR_APP_URL");

// add the chat plugin
cyxth.register([Chat]);

// authorize user
// check https://cyxth.com/docs/authorize for more info
await cyxth.connect(USER_TOKEN_SMH);
const chat: Chat = cyxth.chat();

sending a message

// ..
// simple text message
chat.send("channelId", "hello world");

//or custom data message with reply
chat.send("channelId", {
    data : {
        wallet_qr: "private.png",
        amount: 0.0006,
        productId: "product"
    },
    replyTo: '7890897834984'
})

// ...

receive and handle messages

chat.on("message",(msg) => {
    console.log(`message on ${msg.channelId} from ${msg.sender}`,msg)
})

read more
cyxth quick start
chat reference
chat example
cyxth docs

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i @cyxth/chat

    Weekly Downloads

    4

    Version

    0.0.8-beta.0

    License

    BSD-3-Clause

    Unpacked Size

    23.6 kB

    Total Files

    8

    Last publish

    Collaborators

    • cyxthdev