Loading

Installation

Introduction › Get started › Installation

DocStack ships as two packages on npm: the engine and the React bindings. Both are pre-1.0 and moving, and both are in production use.

The engine

npm install @docstack/client pouchdb-browser pouchdb-find

pouchdb-browser and pouchdb-find are peer dependencies at ^9. DocStack does not bundle the storage layer, so you control its version and it is never duplicated in your bundle.

The same package runs under Node 20 and later, which is what the server is built on. Node’s node export condition resolves @docstack/client to a build that uses pouchdb (LevelDB, http, replication) instead of pouchdb-browser; the engine is the same code, only the constructor differs. A Node consumer installs pouchdb and imports the same names:

npm install @docstack/client pouchdb pouchdb-find   # Node

@docstack/client/node and @docstack/client/browser name each build explicitly, for bundlers and test runners that ignore export conditions.

@docstack/client on npm

The badge is the current release, read from npm as you load this page. The release notes say what changed in each one, and the changelog goes back to 0.1.6.

The React bindings

npm install @docstack/react @docstack/client pouchdb-browser pouchdb-find

React 19 is a peer dependency. @docstack/react wraps the client in a provider and a set of hooks that are live by default; see React bindings.

@docstack/react on npm

What the runtime needs

  • IndexedDB in the browser, LevelDB under Node. The default storage adapter is the one the resolved PouchDB build ships. Any other PouchDB adapter passes through: everything in the options object that is not DocStack’s own reaches the PouchDB constructor, so adapter: 'memory' with plugins: [MemoryAdapter] gives you an in-memory stack for tests.
  • Web Crypto. Field-level encryption uses crypto.subtle for AES-GCM and PBKDF2. Every evergreen browser has it; so does Node 20 and later.
  • WebAssembly, only if you use cryptographic access scopes. The CP-ABE primitive ships as @docstack/abe, a client dependency inlined into the bundle. Its ~180 KB (gzipped) WebAssembly module is embedded but instantiated lazily — a stack that never touches scopes compiles no WebAssembly and pays only the embedded bytes.
  • ES modules. The package is "type": "module", with a browser entry (lib/index.js) and a Node entry (lib/node.js) selected by export condition. A UMD build is also shipped at lib/index.umd.js for script-tag use.
  • TypeScript types resolve @docstack/shared at ^0.1.0. The runtime bundle inlines it (and @docstack/abe); only the published .d.ts files import them.

Bundler note

PouchDB’s browser build touches Node built-ins. Vite projects need a polyfill plugin; the example app in the repository uses vite-plugin-node-polyfills:

vite.config.ts

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { nodePolyfills } from 'vite-plugin-node-polyfills';

export default defineConfig({
    plugins: [
        react(),
        nodePolyfills({ include: ['fs', 'path', 'util', 'stream', 'buffer', 'process'] }),
    ],
});

Webpack 5 projects need the equivalent resolve.fallback entries for buffer, stream, util and process.

Syncing to Google Drive

The Drive transport is a separate package, maintained in its own repository:

npm install @docstack/pouchdb-adapter-googledrive

Use 0.1.6 or later; earlier versions lose change-log references under concurrent writers. The Google Drive guide covers registration, scopes and restore.

The server

@docstack/server is a preview of the same engine deployed on a host. It is not published and there is nothing to install; the server reference describes what it is for and what its source exposes today.

Next

The Quickstart opens a database, defines a class, writes a document and queries it back, first from plain TypeScript and then from React.