Skip to content

worker-sync-dbOffline-first IndexedDB for web apps

Live multi-tab updates and sync to your own API — TypeScript core, optional React hooks.

Install ​

bash
npm install worker-sync-db
typescript
import {
  createDatabase,
  defineSchema,
  sharedWorkerUrl,
  dedicatedWorkerUrl,
} from 'worker-sync-db';

const schema = defineSchema({
  todos: { keyPath: 'id', indexes: { byStatus: 'status' } },
});

const db = await createDatabase({
  schema,
  dbName: 'my-app',
  sharedWorker: sharedWorkerUrl,
  dedicatedWorker: dedicatedWorkerUrl,
});

await db.put('todos', { id: '1', title: 'Buy milk', status: 'open' });

Continue in Getting started or try the live demo in two browser tabs.

MIT License · offline-first IndexedDB with SharedWorker sync