node package manager


A simple connect middleware for rapidly creating pages


npm install connect connect-simple


Use the connect middleware like so...

var connect = require('connect');
var simple = require('connect-simple');
var app = connect().use(new simple({root: './www'})).listen(3000);

In your app's root directory, create the file ./www/index.js

var ua = this.req.headers['user-agent'];

Start your app, and go to http://localhost:3000, you should see your browser's user agent

You can add js files to the /www folder and you will be able to access them in your browser, for example http://localhost:3000/test will resolve to ./www/test.js

The contents of the JavaScript files will be evaluated in a function, from within a SimpleObject

The variable this.req will refer to the node.js request object.

There will also be a variable called this.res which will refer to the node.js response object.


In some cases, there may be things that you will need access to in all your pages (for example, underscore), you can do this by importing them:

var connect = require('connect');
var simple = require('connect-simple');
var underscore = require('underscore');
var app = connect()
            .use(new simple({
                root: './www',
                imports: {
                    '_' : underscore

In this example, you will be able to access underscore from within your pages: this._

Todo List

  • Watch for files that have changed and then update the cache
  • Logging