{"library":"pouchdb-adapter-http","title":"PouchDB HTTP Adapter","description":"pouchdb-adapter-http is a PouchDB plugin that enables the core PouchDB library to use HTTP as its data store, allowing it to seamlessly communicate and synchronize with remote CouchDB or CouchDB-like databases. This adapter is crucial for applications requiring offline-first capabilities combined with cloud synchronization. Currently stable at version 9.0.0, PouchDB maintains a consistent release cadence with frequent patch updates and less frequent major/minor versions. Key differentiators include its ability to abstract away the complexities of HTTP requests and responses, providing a familiar PouchDB API for remote data operations, and its design for use in both Node.js and browser environments, making it a versatile component within the PouchDB ecosystem.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install pouchdb-adapter-http"],"cli":null},"imports":["import PouchDB from 'pouchdb';","import HttpPouch from 'pouchdb-adapter-http';","import PouchDB from 'pouchdb';\nimport HttpPouch from 'pouchdb-adapter-http';\nPouchDB.plugin(HttpPouch);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import PouchDB from 'pouchdb';\nimport HttpPouch from 'pouchdb-adapter-http';\n\nPouchDB.plugin(HttpPouch);\n\n// Create a PouchDB instance that connects to a remote CouchDB via HTTP\nconst remoteDbUrl = process.env.COUCHDB_URL ?? 'http://127.0.0.1:5984/mydb';\nconst db = new PouchDB(remoteDbUrl);\n\nasync function runExample() {\n  try {\n    // Add a document\n    const doc = {\n      _id: 'mydoc-1',\n      title: 'Hello PouchDB HTTP',\n      description: 'This document is stored remotely.'\n    };\n    const response = await db.put(doc);\n    console.log('Document added:', response);\n\n    // Get the document\n    const fetchedDoc = await db.get('mydoc-1');\n    console.log('Document fetched:', fetchedDoc);\n\n    // You can also listen to changes, replicate, etc.\n    console.log(`PouchDB adapter in use: ${db.adapter}`);\n\n  } catch (err) {\n    console.error('Error:', err);\n  }\n}\n\nrunExample();","lang":"typescript","description":"This quickstart demonstrates how to import and register the HTTP adapter, then connect to a remote CouchDB instance, add a document, and retrieve it.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}