Cettia JavaScript Client A is a lightweight B JavaScript client for browser-based C and Node-based D application.

Cettia 1.0.0-Alpha2 client.
14.27KB minified, 5.18KB minified and gzipped.
It has no dependency and follows jQuery 1.x's browser support that embraces Internet Explorer 6.
Though browser is the first runtime, it runs seamlessly on Node.js.

Quick Start

Cettia JavaScript Client is distributed at two places according to runtime engine: browser version through this web site in compressed and uncompressed forms and node version through npm.


<script src="/cettia/cettia.min.js"></script>


var cettia = require("cettia-client");

Once you’ve loaded the module, you will be able to write the following echo and chat client. This page already loaded the uncompressed version, hence, you can run and debug it directly by copying and pasting to JavaScript console if possible.

var socket = cettia.open("http://localhost:8080/cettia");

// Lifecycle events
// When the server issues a new id for this socket as the beginning of the lifecycle and the end of the previous lifecycle
socket.on("new", function() {
    console.log("on new");
// When the selected transport starts connecting to the server
socket.on("connecting", function() {
    console.log("on connecting");
// When the connection is established successfully
socket.on("open", function() {
    console.log("on open");
// When an error happens on the socket
socket.on("error", function(error) {
    console.error("on error", error);
// When the connection is closed, regarded as closed or could not be opened
socket.on("close", function() {
    console.log("on close");
// When a reconnection is scheduled
socket.on("waiting", function(delay, attempts) {
    console.log("on waiting", attempts, delay);

// echo and chat events
socket.on("open", function() {
    socket.send("echo", "An echo message");
    socket.send("chat", "A chat message");
socket.on("echo", function(data) {
    console.log("on echo", data);
socket.on("chat", function(data) {
    console.log("on chat", data);

Further Reading

  • To play something right now, start with archetype example.
  • To take a brief look at API, check out the testee.
  • To get details of API, see API document.
  • To have a thorough knowledge of the implementation, read out the reference.