Registry / storage / capacitor-localstorage-migration

capacitor-localstorage-migration

JSON →
library1.2.0jsnpmunverified

Capacitor plugin (v1.2.0) to migrate legacy localStorage data from UIWebView (iOS) and Crosswalk WebView (Android) to modern Capacitor WebViews. Supports both Crosswalk SQLite and system WebView LevelDB formats. Preserves original database files for safety and allows retry. Peer dep on @capacitor/core >=7.0.0. Ships TypeScript types. Released ~2023, no active development observed. Key differentiator: handles both SQLite and LevelDB, uses hidden WebView for reliable LevelDB access.

npm install capacitor-localstorage-migration
INSTALL
IMPORT
SIG · CAPACITOR-LOCALSTO
C
capacitor-localstorage-migration
storagejavascriptv1.2.0
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.

LocalStorageMigration
import { LocalStorageMigration } from 'capacitor-localstorage-migration'
import LocalStorageMigration from 'capacitor-localstorage-migration'
Named export; default import is not provided.
getLegacyData
const data = await LocalStorageMigration.getLegacyData()
import { getLegacyData } from 'capacitor-localstorage-migration'
getLegacyData is a method of the exported class, not a standalone function.
Capacitor
import { Capacitor } from '@capacitor/core'; const isNative = Capacitor.isNativePlatform()
import { Capacitor } from 'capacitor-localstorage-migration'
Capacitor core utilities are from @capacitor/core, not this plugin.

Complete migration of legacy localStorage from old WebViews, with completion flag to avoid re-runs.

import { LocalStorageMigration } from 'capacitor-localstorage-migration'; async function migrateLocalStorage() { try { if (localStorage.getItem('migrationCompleted')) { console.log('Migration already completed'); return true; } const data = await LocalStorageMigration.getLegacyData(); if (data && Object.keys(data).length > 0) { Object.entries(data).forEach(([key, value]) => { localStorage.setItem(key, value); }); localStorage.setItem('migrationCompleted', 'true'); console.log('Migration successful', data); return true; } else { localStorage.setItem('migrationCompleted', 'true'); console.log('No legacy data found'); return false; } } catch (err) { console.error('Migration failed:', err); return false; } }
Debug
Known issues
breakingRequires @capacitor/core >=7.0.0. Older Capacitor versions are incompatible.
fix
Update @capacitor/core to version 7 or later.
affects: >=1.0.0
gotchaPlugin only works on actual iOS/Android devices or emulators; calling getLegacyData() on a web browser will throw an error because Capacitor native plugins are not available.
fix
Wrap calls in platform checks: import { Capacitor } from '@capacitor/core'; if (Capacitor.isNativePlatform()) { ... }
affects: >=1.0.0
gotchagetLegacyData() returns an empty object if no legacy data exists, not null or undefined. Code must check Object.keys(data).length > 0 to avoid false positives.
fix
Use Object.keys(data).length > 0 to test for existence of data.
affects: >=1.0.0
deprecatedUIWebView is deprecated on iOS; this plugin only supports data migration from UIWebView, not WKWebView. Modern apps on iOS should not rely on UIWebView data.
fix
For WKWebView data persistence, use standard localStorage or a different migration strategy.
affects: >=1.0.0
gotchaOn Android, the plugin checks Crosswalk SQLite first, then falls back to system WebView LevelDB. If both are absent, it returns an empty object — no error is thrown.
fix
Check returned data length; if zero, consider alternative migration paths.
affects: >=1.0.0
Errors
Common errors & fixes
Error: "LocalStorageMigration" is not a constructor
Using a default import instead of the named import.
fix
Change to: import { LocalStorageMigration } from 'capacitor-localstorage-migration'
Uncaught (in promise) Error: Plugin does not exist on this platform
Calling getLegacyData() on a non-native platform (e.g., browser).
fix
Guard with platform check: if (Capacitor.isNativePlatform()) { ... }
TypeError: Cannot read properties of undefined (reading 'getLegacyData')
Plugin not synced with Capacitor (missing npx cap sync) or not installed on the native project.
fix
Run 'npx cap sync' after installing the plugin.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
@capacitor/corerequiredRuntime peer dependency for Capacitor plugin contract
Agent activity
30 hits · last 30 days
node
28
OpenAI (training)
1
Resources
capacitor-localstorage-migration — npm install capacitor-localstorage-migration · libregistry