A chat room
in your terminal.
Real-time chat rooms from the command line, no sign-up.
npx @matheussartori/hackerchat-clientOne server in the middle, clients around it.
Each person joins from a terminal or a browser. The server takes every message and passes it to everyone in the room.
Terminal client
Built with Ink, which is React drawn in the terminal. Rooms, who is online, a scrollable history and a fixed colour per person.
GitHub: hackerchat-terminal-client (opens in a new tab)npm: @matheussartori/hackerchat-client (opens in a new tab)
WebSocket server
A Node.js hub that opens a room when someone joins and passes messages along. No database, no sign-up, everything in memory.
JavaScript SDK
A client for the browser or Node, with React hooks. Wires any interface to the server in a few lines.
GitHub: hackerchat-js-sdk (opens in a new tab)npm: @matheussartori/hackerchat-js-sdk (opens in a new tab)
Three terminals, one minute.
The public server has been switched off. Run your own locally and point the client at it.
# Needs Node.js 24 or newer.
Start the server
Clone the repository and run it in development mode. It listens on port 9898; 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:9898Connect a client
In another terminal, run the client with npx, nothing to install. --username and --room are required; --hostUri points at your server.
terminal 2 npx @matheussartori/hackerchat-client \ --username alice \ --room general \ --hostUri ws://localhost:9898Talk
Open one more terminal with a different name, or join from the playground at the end of the page, and watch the messages land.
terminal 3 npx @matheussartori/hackerchat-client \ --username bob \ --room general \ --hostUri ws://localhost:9898
Join a room from this page.
The room next to this is live right now, over public Nostr relays. Type a name and join. For your own server, the form runs on the SDK below.
import { useHackerchat } from '@matheussartori/hackerchat-js-sdk/react'
const { status, users, messages, sendMessage } = useHackerchat({
url: 'ws://localhost:9898',
userName: 'alice',
roomId: 'general',
})Public room: messages travel through Nostr relays and anyone can read them.
Flags, shortcuts and variables.
Everything the client and the server accept.
Client flags
| Flag | Description | Usage |
|---|---|---|
--username | Display name shown in the room. | required |
--room | Room to join. Created if it does not exist yet. | required |
--hostUri | WebSocket URL of the server, with ws:// or wss://. Without it the client tries the old public address, which is switched off. | recommended |
Interface shortcuts
| Key | Action |
|---|---|
| Enter | Send the message. |
| PgUp / PgDn | Scroll the history one page at a time. |
| Ctrl+U / Ctrl+D | Scroll the history one line at a time. |
| Home / End | Jump to the oldest message or back to the newest. |
| Esc / Ctrl+C | Exit the client. |
Server variables
| Variable | Default | Description |
|---|---|---|
PORT | 9898 | TCP port the server listens on. |
LOG_LEVEL | error | Minimum log level: debug, info, warning or error. |
Four events cover everything.
Join a room, send a message, get the list of who is there and hear when someone comes or goes. Every frame is an event with a payload.
{ "event": "joinRoom",
"message": { "userName": "alice",
"roomId": "general" } }
{ "event": "message",
"message": "hello, world" }{ "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" } }Want a shorter command?
Install the client globally and call hackerchat directly.
npm install -g @matheussartori/hackerchat-client
hackerchat --username alice --room general --hostUri ws://localhost:9898