Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
NowJS makes it easy to build real-time web apps using JavaScript
JavaScript
branch: master

This branch is 135 commits ahead, 46 commits behind Flotype:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
doc Merge branch 'master' of github.com:Flotype/now
examples fixed extraneous code in helloworld example
lib Bringing up to current Flotype head
.gitignore added .gitignore
.gitmodules first commit
LICENSE
best_practices.md Edited best_practices.md via GitHub
changelog.md Edited changelog.md via GitHub
getting_started.md Edited getting_started.md via GitHub
package.json socket.io 0.8.4 dependency
readme.md Edited readme.md via GitHub
user_manual.md Edited user_manual.md via GitHub

readme.md

Get NowJS http://www.nowjs.org/

NowJS makes realtime web apps really easy.

Go to Github or Download the master tgz

Install From npm

npm install now or npm install now -g to install globally

NowJS is a Node.js module. The client javascript (now.js) is served by the NowJS server.

NowJS uses the excellent socket.io and node-proxy libraries.

2 Step Setup

1. On the server

var httpServer = require('http').createServer(function(req, response){ /* Serve your static files */ })
httpServer.listen(8080);

var nowjs = require("now");
var everyone = nowjs.initialize(httpServer);

everyone.now.logStuff = function(msg){
    console.log(msg);
}

2. On the client


<script type="text/javascript" src="http://localhost:8080/nowjs/now.js"></script>

<script type="text/javascript">
  now.ready(function(){
    // "Hello World!" will print on server
    now.logStuff("Hello World!");
  });
</script>

FAQ

Q: Can I pass in a callback or closure, for example, if the remote function is asynchronous?

A: Yes. This is 100% supported

Q: How do I use NowJS with Express?

A: Very easily. var app = express.createServer(); app.listen(3000); var everyone = require("now").initialize(app);

Q: Error: " SyntaxError: Unexpected token *" / Can I statically host the now.js file?

A: On the client side, make sure you link to now.js like this

 <script src="http://myserver:myport/nowjs/now.js"></script>

You do not need to host the file /nowjs/now.js. It is automatically hosted by the NowJS using the http server you pass into the .initialize(...) in your server code. If you choose to host now.js yourself, you can, but do not use the version in github repo you MUST save the file at http://myserver:myport/nowjs/now.js and host that, because it is automatically configured for your server.

Further Reading

Now that you have NowJS, try the NowJS User Manual and Quick Chat Example

Have more questions? Please contact us: Email: team@nowjs.org

IRC: #nowjs on freenode

Twitter: @NowJSTeam

Something went wrong with that request. Please try again.