Adam Stacoviak

twich: php + node.js realtime web-based chat

Twich was first mentioned back in July when the author, Isaac Su, posted a news item to Hacker News titled “I made a browser-based chat app. Based on node.js and nodechat.”. Yesterday (October 27, 2010), Isaac posted another news item to Hacker News titled “Remember (node.js realtime chat)? Here is the source as promised.”, officially open sourcing his code for all the world to see.

Isaac does mention in the #readme that Twich is based on node_chat by Ryan Dahl


See the #readme for more details.


www/ is a set of php scripts that serve up the client files and organize the rooms.

First, create a vhost in Apache and point it to this folder. You will require mod_rewrite for it to function properly.

Then, copy www/_config.php.sample to www/_config.php and enter your own configuration settings. These help to customize the javascript files that are served to the client.

var $port = 443; // Port that  node server is listening on
var $domain = ''; //domain name of node server
var $analyticsAccount = ''; // Google Analytics account
var $analyticsDomainName = ''; // Google Analytics domain name

Finally, edit .htaccess and put your own domain name in instead of

Congrats www/ is all setup


node/ is the actual node server.

First, the configuration is in config.js. The only one you should be worrying about is port:443. This has to match $port in _config.php.

Start the node server by typing: node server.js

Check out the Codes

[Source on GitHub]


Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00