indexeddb-export-import is a JavaScript utility for serializing and deserializing IndexedDB databases to and from JSON format. It provides functions to export an entire database to a JSON string, import data from a JSON string into an existing database, and clear all data from a database. The package is currently at version 2.1.5 and maintains an active release cadence, primarily focusing on bug fixes and minor improvements. A key differentiator is its minimal footprint, having zero runtime dependencies since version 2.0.0, making it lightweight for both Node.js (especially Electron apps) and browser environments, where it can be included directly via a `<script>` tag. It requires ES6 (Node.js 8+ or modern browsers) since its v2 release, offering a clean API for database backup, restoration, and development/testing workflows.
npm install indexeddb-export-importVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to export an IndexedDB database to a JSON string, clear all its object stores, and then re-import the data from the previously exported JSON string. It uses Dexie.js to manage the IndexedDB connection for convenience, which is a common pattern for obtaining an `IDBDatabase` instance.
Upgrade your Node.js runtime to version 8 or higher, or ensure your browser environment supports ES6. If targeting ES5, consider using Babel or downgrade to a v1.x version of `indexeddb-export-import`.
Update to version 2.1.5 or later to ensure robust handling of object store key mismatches during import. This version fixes issues where import JSON is missing keys or contains keys not present as object store names.
If you intend to completely restore a database or prevent key clashes, always call `clearDatabase` before `importFromJsonString`. Ensure your application logic handles potential key conflicts if partial imports are desired.
No direct fix needed unless your project implicitly relied on a removed transitive dependency. This is primarily an internal architecture change with positive effects.
Ensure the JSON structure exactly matches the object store names in your `IDBDatabase`. Upgrade to `indexeddb-export-import@2.1.5` or later to mitigate issues with missing/extra keys.
For browser usage without a bundler, include the library via a `<script>` tag. If using a bundler, configure it to handle CommonJS modules or use ES module `import` syntax if your project supports it.
No dependency data recorded yet.