GitHub

Setting up PouchDB

Installing PouchDB is easy. There are a few different ways to do it:

Download the latest pouchdb-9.0.0.min.js from the big green button above. Then in your index.html:

<script src="pouchdb-9.0.0.min.js"></script>

Run this on the command line:

$ bower install pouchdb

Then in your index.html:

<script src="bower_components/pouchdb/dist/pouchdb.min.js"></script>

Run this on the command line:

$ npm install pouchdb

Then in your index.html:

<script src="node_modules/pouchdb/dist/pouchdb.min.js"></script>

Add this to your index.html:

<script src="//cdn.jsdelivr.net/npm/pouchdb@9.0.0/dist/pouchdb.min.js"></script>

Run this on the command line:

$ npm install pouchdb

Then in your JavaScript:

const PouchDB = require('pouchdb');

Run this on the command line:

$ npm install pouchdb @types/pouchdb

In your tsconfig.json activate allowSyntheticDefaultImports:

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true
  }
}

Then in your TypeScript:

import * as PouchDB from 'pouchdb';

You can install a plugin (provided there is a type definition for it in npm), import it in the same way and then pass the imported name to PouchDB.plugin() method just as you would do in JavaScript.

Now that you have PouchDB installed, let's start working with databases.