Registry / database / dexie-mysql-sync

dexie-mysql-sync

JSON →
library6.0.1jsnpmunverified

Synchronization library between local IndexedDB (via Dexie.js) and a remote MySQL database. Current stable version is 6.0.1, released 2024-03-01. Provides automatic two-way sync with conflict resolution, optional user authentication, and multi-tenancy support. Powered by Dexie.js and PHP CRUD API. Key differentiators: it directly syncs IndexedDB tables to MySQL tables with minimal configuration, supports UUID-based IDs, and includes built-in fields for tracking creation, update, deletion, and synchronization timestamps.

npm install dexie-mysql-sync
INSTALL
IMPORT
SIG · DEXIE-MYSQL-SYNC
D
dexie-mysql-sync
databasejavascriptv6.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Sync
import Sync from 'dexie-mysql-sync'
import { Sync } from 'dexie-mysql-sync'
Default export only; named import will cause undefined.
default export
const Sync = require('dexie-mysql-sync').default
const Sync = require('dexie-mysql-sync')
In CommonJS, use .default to get the constructor, or enable esModuleInterop.
TypeScript type
import type { Sync } from 'dexie-mysql-sync'; import Sync from 'dexie-mysql-sync'
import { Sync } from 'dexie-mysql-sync'
TypeScript: use type import for types and default import for value. The package does not export a named Sync type; use manual type declaration.

Shows how to initialize Dexie, add a table, and start MySQL synchronization with a custom endpoint.

import Dexie from 'dexie'; import Sync from 'dexie-mysql-sync'; const db = new Dexie('myDatabase'); db.version(1).stores({ tasks: '++id, title, $created, $deleted' }); const sync = new Sync('https://example.com/api.php'); sync.add(db.tasks, 'tasks'); export { db, sync };
Debug
Known issues
breakingVersion 6.x requires PHP CRUD API v2.x or later; v1.x endpoints are incompatible.
fix
Update your PHP CRUD API to version 2.x or use an older dexie-mysql-sync version (<=5.x).
affects: >=2.0.0
deprecatedThe 'autoSync' option has been removed in v6; sync is always on.
fix
Remove any 'autoSync' configuration passed to Sync constructor.
affects: >=6.0.0
gotchaSynchronization will fail silently if MySQL table does not contain required columns: id, userId, $created, $updated, $deleted, $synchronized.
fix
Ensure all MySQL tables have these columns with correct types (see README schema.sql).
affects: >=1.0.0
gotchaUsing 'http' or 'localhost' endpoints may trigger CORS errors in browser; use 'https' and proper subdomain or same-origin.
fix
Use a relative path (e.g., '/api.php') instead of full URL, or configure CORS headers on the PHP backend.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: dexie_mysql_sync_1.default is not a constructor
CommonJS import without .default (missing esModuleInterop).
fix
Use 'import Sync from 'dexie-mysql-sync';' or in CJS: const Sync = require('dexie-mysql-sync').default;
Uncaught (in promise) TypeError: db.tasks is undefined
Store schema not defined before using sync.add.
fix
Ensure db.version().stores() is called before creating Sync instance and calling sync.add().
Error: Cannot read properties of undefined (reading 'push')
MySQL table missing required columns or PHP CRUD API not configured properly.
fix
Check that MySQL table has all required columns (id, userId, $created, $updated, $deleted, $synchronized) and that PHP CRUD API endpoint is correct.
Upgrade
Version history
6.0.1latest on npm
Audit
Dependencies
dexierequiredpeer dependency - Dexie.js is required for IndexedDB interaction
Agent activity
5 hits · last 30 days
node
4
Resources
dexie-mysql-sync — npm install dexie-mysql-sync · libregistry