Real-time chat, without
leaving the terminal.

hackerchat is a chat client that runs in the terminal, a lean WebSocket server and a JavaScript SDK. Start the server, join a room and talk straight from your shell, or from any interface that speaks WebSocket.

View on GitHub (opens in a new tab)
$

Three parts, one protocol.

Client, server and SDK exchange JSON frames over WebSocket. Each part is its own repository, and any of them can be swapped for an implementation of your own.

WebSocket server

A Node.js hub that creates rooms on demand and routes messages between connected clients. No database, no sign-up, no state outside memory.

The protocol on the wire

Every message is a JSON object with an event and a payload. Four events cover everything: joining a room, sending a message, receiving the user list and hearing when someone comes or goes.

client sends
{ "event": "joinRoom",
  "message": { "userName": "alice",
               "roomId": "general" } }

{ "event": "message",
  "message": "hello, world" }
server replies
{ "event": "updateUsers",
  "message": [{ "id": "…", "userName": "alice" }] }

{ "event": "newUserConnected",
  "message": { "id": "…", "userName": "alice" } }

{ "event": "message",
  "message": { "userName": "alice",
               "message": "hello, world" } }

{ "event": "disconnectUser",
  "message": { "id": "…", "userName": "alice" } }

Running in two terminals.

The public server has been retired. Clone the server, run it locally and point the client at it. It takes under a minute.

Requires Node.js 24 or newer.

  1. Start the server

    Clone the repository and run it in development mode. It listens on port 9898 by default; set PORT to change that.

    terminal 1
    git clone https://github.com/matheussartori/hackerchat-server.git
    cd hackerchat-server
    npm install
    npm run dev
    # listening on ws://0.0.0.0:9898
  2. Connect a client

    In another terminal, run the client with npx, nothing to install. The --username and --room flags are required, and --hostUri points at your server.

    terminal 2
    npx @matheussartori/hackerchat-client \
      --username alice \
      --room general \
      --hostUri ws://localhost:9898
  3. Chat

    Open a third terminal with a different username, or join from the playground at the bottom of the page, and watch messages arrive in real time.

    terminal 3
    npx @matheussartori/hackerchat-client \
      --username bob \
      --room general \
      --hostUri ws://localhost:9898

Prefer a shorter command?

Install the client globally and call hackerchat directly.

global install
npm install -g @matheussartori/hackerchat-client
hackerchat --username alice --room general --hostUri ws://localhost:9898

Flags, shortcuts and variables.

Everything the client and the server accept, in one place.

Client flags
flagdescriptionusage
--usernameDisplay name shown in the room.required
--roomRoom to join. Created if it does not exist yet.required
--hostUriWebSocket URL of the server, with ws:// or wss://. Without it the client tries the old public address, which has been retired.recommended
Interface shortcuts
keyaction
EnterSend the message.
PgUp / PgDnScroll the history one page at a time.
Ctrl+U / Ctrl+DScroll the history one line at a time.
Home / EndJump to the oldest message or back to the newest.
Esc / Ctrl+CExit the client.
Server variables
variabledefaultdescription
PORT9898TCP port the server listens on.
LOG_LEVELerrorMinimum log level: debug, info, warning or error.

Three repositories, two npm packages.

All TypeScript, all MIT. The server is not published to npm: clone it and run it.

Try the SDK in the browser.

This section uses @matheussartori/hackerchat-js-sdk to connect to a hackerchat server. Start a local server, or enter the address of your own, and join a room.

what runs behind it
import { useHackerchat } from '@matheussartori/hackerchat-js-sdk/react'

const { status, users, messages, sendMessage } = useHackerchat({
  url: 'ws://localhost:9898',
  userName: 'alice',
  roomId: 'general',
})

Connect

Full WebSocket URL, with ws:// or wss://.
How you appear in the room.
Letters, numbers and dashes. Created if it does not exist.
localhost addresses work even though this page is served over HTTPS.