Skip to content
CouchDB in the browser
Pull request Compare This branch is 4 commits ahead of peterbraden:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



This is experimental proxy server in node.js. It does two basic things:

  • serves as a proxy between browser and your web server as well as CouchDB,
  • WebSockets for fast master-slave replication with CouchDB.


  • Browsers, for security reasons, don’t allow cross-domain ajax request, required for full CouchDB support = need for web and couch server to be available on the same port,
  • WebWorkers are good for reducing load and optimizing speed especially for extensive master-to-many-slaves replications.


Fire up your CouchDB server:

$ couchdb
Apache CouchDB 1.0.0 (LogLevel=info) is starting.
Apache CouchDB has started. Time to relax.
[info] [<0.33.0>] Apache CouchDB has started on

Fire up your web server:

$ cd ./html/
$ thin -A file start
>> Using file adapter
>> Thin web server (v1.2.7 codename No Hup)
>> Maximum connections set to 1024
>> Listening on, CTRL+C to stop

Fire up our proxy server (it may require root):

$ node server.js
25 Jul 21:03:34 - ready - accepting connections

Open browser (which supports WebSockets like newest Chrome or Firefox) and go to:
This is console. You can do basic CRUD request to your DB. For example select PUT and enter: /. It will create new database “browsercouch” (which is default name. You can change it in ./server.js file).

Refresh page, open another browser window and go to the same console page. Then choose POST and type / {"hello": "world"}. This will save new document in database. Notice how fast this update appeared in the other browser window.


  • Replace BrowserCouch’s ajax replications with WebSockets,
  • pass specs,
  • make similar console for communication with BrowserCouch.
Something went wrong with that request. Please try again.