Getting Started with PouchDB to Replace Parse

Feb 22, 2016

With the demise of Parse, I had to be receptive to alternatives. Luckily I had already been suggested a contender, PouchDB. Theoretically, the first thing needed is to create a JSON payload with some important data you need to replicate from the client.

Now, where is this data going to be stored?

If you are already using indexedDB for client-side storage of JSON documents, PouchDB could make storing that data on the server a whole lot simpler.

Even for strictly local development, the system seems quite useful.


CAP theorem, named after the three guarantees that are supposed to be impossible to achieve simultaneously in distributed systems, can help show where mongoDB and CouchDB differ.

Practically this means the PouchDB/CouchDB is updated in a more distributed, eventually consistent manner. Whereas MongoDB has a central node that coordinates all reads and writes to the secondary stores.

So what is PouchDB? It’s an in-browser database, with the same API as CouchDB, but as suggested by the name, a portable version. Even npm runs using CouchDB. But that was a relatively recent 2014.

It uses a REST like API. So mainly you will be using GET, PUT, POST, HEAD, DELETE to interact with your data.

Now to get started with your project:

npm init

npm i pouchdb —save

then require,


 PouchDB = require('pouchdb');


 db = new PouchDB('Local_database');

A unique _id property is necessary on each object. Any new data set on objects with the same _id property will merely update that object.

First set up the listener and add data. Listen for changes on the db object:


since: 'now',

live: true

}).on('change', showData);

Add the data to the db object:




data = {


title: title,

completed: false




cb(err, result){





('error: ', err);




Once you put some JSON data into the pouch db instance, to retrieve that data just use an accessor method on the db instance, like allDocs.




{include_docs: true, descending: true},


(err, doc) {



Now that you have verified that data has been added, sync the data with something you need at least a local pouchDB database and a remote couchDB database.

To test syncing you need to have setup CouchDB. From the Futon admin interface, the data can be seen syncing.


To replicate a PouchDB you need a CouchDB instance. you can download it from .

or use .




Couched needs to be CORS enabled.

The methods GET, PUT, POST, HEAD, DELETE need to be added in the core config.

You can go to http://localhost:5984/_utils/config.html add a new section then set credentials to true;

headers to accept, authorization, content-type, origin, referer;

methods to GET, PUT, POST, HEAD, DELETE;


origins to * .

Lastly make sure the config key the httpd is set to true for the enable_cors option.

Now that CouchDB is setup you try syncing



CouchDB_URI = 'http://localhost:5984/pouch';







and what you get is:

Another benefit of using pouchDB for files is that it can handle images and store them to blob for you as well as syncing it.

Lastly, if you were worried about migrations, don’t. New versions of PouchDB auto migrate so that your PouchDB can be accessed from the new version of PouchDB.

With pouchdb syncing data becomes quite simple. It’s just a matter of locating the path to your remote db and the name of the local db. Then it just 2 replicate calls away from syncing the data which you can bypass with a single sync call.




Meet Sourcetoad, a 2023 Best Places to Work honoree

Meet Sourcetoad, a 2023 Best Places to Work honoree

Tampa Bay Business Journal — April 26, 2023 Sourcetoad has been selected as a 2023 Best Places to Work! We are thrilled to be among Tampa's top workplaces for the fourth year in a row, and we are grateful to each of our Toads for making Sourcetoad such a fantastic...

This Year in FinTech: Trends to Watch in 2023

This Year in FinTech: Trends to Watch in 2023

The financial services industry experienced rapid digitization throughout the COVID-19 pandemic, and growth of the financial technology market is expected to continue in 2023. The global fintech market grew to $158.9 billion in 2022, and projections estimate it will...

2023 Top HealthTech Trends

2023 Top HealthTech Trends

Technological innovation has played a vital role in the transformation and growth of the healthcare industry. Not only is the medical space an early adopter of emerging technologies, HealthTech is currently one of the fastest-growing industries worldwide. The global...