# js-collaboration

## Content

`js-collaboration` is a library enabling **low-latency**, **bidirectional communication** for real-time data synchronization between the client and the server.​ It is divided into the client side ([js-collaboration-client](/spreadjs/api/collaboration/js-collaboration-client/README#spreadjs-api)) and the server side ([js-collaboration](/spreadjs/api/collaboration/js-collaboration/README#spreadjs-api)).

## Core Features

* **Bidirectional Connection:** Enables bidirectional client-server communication with real-time data synchronization guarantees.
* **Rooms**: Supports room lifecycle operations (create/join/leave) for organized multi-user coordination.
* **Broadcasting**: Enables message broadcasting to all room participants with real-time notification delivery.
* **Heartbeat and Auto Reconnect**: Implements heartbeat monitoring and automatic reconnection mechanisms to maintain persistent connectivity.
* **Middleware and Hook System​**:
    * Middleware provides a mechanism for inserting custom logic during connection and message handling processes. It enables user to hook into the server pipeline, to handles authentication, permissions, etc.
    * Hooks provides a mechanism for triggering custom processing logic when key events occur.

## About Room

Initialization phase completes when the client initiates a WebSocket connection to the server. The server employs a ​**​room-based architecture​**​ to manage concurrent client sessions, where each room represents an isolated synchronization context. During collaboration, the server **broadcasts** real-time messages to clients within the same room via the broadcast mechanism.
Learn more about broadcast, see [Messages Sending and Receiving](/spreadjs/docs/spreadjs-collaboration-server/collaboration-framework/js-collaboration/messages-sending-and-receiving).​
![overview-room](https://cdn.mescius.io/document-site-files/images/7719ad0a-f083-46d7-aff6-f63e2e187c15/overview-room.4e4969.png?width=500&verticalAlign=middle)

## Next steps

Follow these step-by-step tutorials to build a real-time chat room and implement user authentication functionality using `js-collaboration`:

* [Tutorial: Real-Time Chat Room](/spreadjs/docs/spreadjs-collaboration-server/collaboration-framework/js-collaboration/tutorial-real-time-chat-room)
* [Tutorial: Add Authentication](/spreadjs/docs/spreadjs-collaboration-server/collaboration-framework/js-collaboration/tutorial-real-time-chat-room/tutorial-add-authentication)

Master core concepts and APIs of `js-collaboration`, covering:

* client/server initialization
* real-time connection management
* server middleware mechanism
* implementation of message sending and receiving
* authorization system construction

Each module will demonstrate practical usage via code examples. It is recommended to gradually practice by following the tutorial path in the left-hand navigation bar.