Nurturing Pluto's Martians
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »


0.6.0 • Public • Published


Pure Streaming Chat for Node. This is a simple library which implements the core concepts of chat (rooms and connections) without getting tying chat to any particular transport.

Getting Started

The first thing you are going to want to do is create a room:

var chat = require('chat'),
    room =;

Once you have a room, you can then start connecting clients to the room:

var client = chat.client(room);

At this point, we should probably start listening for messages in the room:

room.on('message', function(msg) {
    if ( {

The code above looks specifically for just the data messages that are captured by the room. In addition to the data messages, control messages are also sent which can be captured by examining the type property of the message.

At this point, it's probably worth attempting to communicate with the room. This is done using the write method of the client:


Strange, we didn't capture any output. This is because as far as the room is concerned, an unknown client is attempting to send messages and this isn't permitted. While the chat package doesn't perform any authentication it does assume that a package using chat (such as iceman) will. So at a base level, it requires identification:

client.identify({ nick: 'Bill' });

Calling identify on the client stream kicks off a handshake process with the room, and thus we should wait for the client to become ready before writing any messages:

client.once('ready', function(metadata) {

For the full example, see examples/hello.js.

Transport Free

Obviously, this isn't the first chat implementation written in Node. It is, however, one of the first to be written that isn't tied to a specific transport implementation (usually WebSockets).

An example of a pure socket level chat server and client can be found in the examples directory.




npm i chat

Downloadsweekly downloads








last publish


  • avatar