Svelte initialization with PouchDB
11:27 25 Jul 2026

I'm writing my first Svelte application, and learning modern ECMAScript at the same time. I have a file in the lib directory called 'dataStore.js' that defines a class called DataStore (to isolate pouchdb away in case I want to switch to something else).

import PouchDB from 'pouchdb-browser'

PouchDB.plugin(require('pouchdb-authentication'));
console.log("added plugin");

const COUCHURL = "http://127.0.0.1:5984/";

export default class DataStore {
  #localDB;
  #remoteDB;

  constructor(dbName) {
    try {
      this.#localDB = new PouchDB(dbName);
      this.#remoteDB = new PouchDB(COUCHURL + dbName, { skip_setup: true });
      console.log("ctor");
    } catch (error) {
      console.error("wtf", error);
    }
  }
};

And in routes/+page.svelte I'm trying to use that class. I get a compile time error if I just import DataStore from '$lib/dataStore' so I changed it to use an await import in an onMount to make sure it only happens in the browser. That eliminates the compile time error, but in the dev console, I get an error deep inside pouchdb-browser.js.

This is +page.svelte


Welcome to SvelteKit

Visit svelte.dev/docs/kit to read the documentation

And this is the error I see:

pouchdb-browser.js?v=992f7d31:1032 Uncaught (in promise) TypeError: Class extends value [object Object] is not a constructor or null
    at pouchdb-browser.js?v=992f7d31:1032:60
(anonymous) @   pouchdb-browser.js?v=992f7d31:1032
svelte pouchdb svelte-5