Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stream-chat

Package Overview
Dependencies
Maintainers
10
Versions
299
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-chat

JS SDK for the Stream Chat API

  • 8.40.5
  • Source
  • npm
  • Socket score

Version published
Maintainers
10
Created

What is stream-chat?

The stream-chat npm package is a powerful tool for building chat applications. It provides a comprehensive set of features for real-time messaging, user management, and chat room creation, among others. It is designed to be highly customizable and scalable, making it suitable for a wide range of applications from simple chat widgets to complex messaging platforms.

What are stream-chat's main functionalities?

Real-time Messaging

This feature allows you to send real-time messages in a chat channel. The code sample demonstrates how to initialize the StreamChat client, create a channel, and send a message.

const StreamChat = require('stream-chat').StreamChat;
const client = new StreamChat('api_key');

async function sendMessage() {
  const channel = client.channel('messaging', 'general', {
    name: 'General Chat',
  });
  await channel.create();
  await channel.sendMessage({
    text: 'Hello, world!',
    user_id: 'user123',
  });
}
sendMessage();

User Management

This feature allows you to manage users within the chat application. The code sample demonstrates how to create or update a user with specific attributes.

const StreamChat = require('stream-chat').StreamChat;
const client = new StreamChat('api_key');

async function createUser() {
  await client.upsertUser({
    id: 'user123',
    name: 'John Doe',
    role: 'user',
  });
}
createUser();

Channel Management

This feature allows you to manage chat channels. The code sample demonstrates how to create a new chat channel with a specific name and type.

const StreamChat = require('stream-chat').StreamChat;
const client = new StreamChat('api_key');

async function createChannel() {
  const channel = client.channel('messaging', 'general', {
    name: 'General Chat',
  });
  await channel.create();
}
createChannel();

Message Reactions

This feature allows users to add reactions to messages. The code sample demonstrates how to send a message and then add a 'like' reaction to that message.

const StreamChat = require('stream-chat').StreamChat;
const client = new StreamChat('api_key');

async function addReaction() {
  const channel = client.channel('messaging', 'general');
  await channel.create();
  const message = await channel.sendMessage({
    text: 'Hello, world!',
    user_id: 'user123',
  });
  await channel.sendReaction(message.id, {
    type: 'like',
    user_id: 'user123',
  });
}
addReaction();

Other packages similar to stream-chat

Keywords

FAQs

Package last updated on 11 Sep 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc