{"id":47222,"library":"capacitor-localstorage-migration","title":"Capacitor LocalStorage Migration","description":"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.","status":"maintenance","version":"1.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/Chuckv01/capacitor-localstorage-migration","tags":["javascript","capacitor","plugin","native","typescript"],"install":[{"cmd":"npm install capacitor-localstorage-migration","lang":"bash","label":"npm"},{"cmd":"yarn add capacitor-localstorage-migration","lang":"bash","label":"yarn"},{"cmd":"pnpm add capacitor-localstorage-migration","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime peer dependency for Capacitor plugin contract","package":"@capacitor/core","optional":false}],"imports":[{"note":"Named export; default import is not provided.","wrong":"import LocalStorageMigration from 'capacitor-localstorage-migration'","symbol":"LocalStorageMigration","correct":"import { LocalStorageMigration } from 'capacitor-localstorage-migration'"},{"note":"getLegacyData is a method of the exported class, not a standalone function.","wrong":"import { getLegacyData } from 'capacitor-localstorage-migration'","symbol":"getLegacyData","correct":"const data = await LocalStorageMigration.getLegacyData()"},{"note":"Capacitor core utilities are from @capacitor/core, not this plugin.","wrong":"import { Capacitor } from 'capacitor-localstorage-migration'","symbol":"Capacitor","correct":"import { Capacitor } from '@capacitor/core'; const isNative = Capacitor.isNativePlatform()"}],"quickstart":{"code":"import { LocalStorageMigration } from 'capacitor-localstorage-migration';\n\nasync function migrateLocalStorage() {\n  try {\n    if (localStorage.getItem('migrationCompleted')) {\n      console.log('Migration already completed');\n      return true;\n    }\n    const data = await LocalStorageMigration.getLegacyData();\n    if (data && Object.keys(data).length > 0) {\n      Object.entries(data).forEach(([key, value]) => {\n        localStorage.setItem(key, value);\n      });\n      localStorage.setItem('migrationCompleted', 'true');\n      console.log('Migration successful', data);\n      return true;\n    } else {\n      localStorage.setItem('migrationCompleted', 'true');\n      console.log('No legacy data found');\n      return false;\n    }\n  } catch (err) {\n    console.error('Migration failed:', err);\n    return false;\n  }\n}","lang":"typescript","description":"Complete migration of legacy localStorage from old WebViews, with completion flag to avoid re-runs."},"warnings":[{"fix":"Update @capacitor/core to version 7 or later.","message":"Requires @capacitor/core >=7.0.0. Older Capacitor versions are incompatible.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Wrap calls in platform checks: import { Capacitor } from '@capacitor/core'; if (Capacitor.isNativePlatform()) { ... }","message":"Plugin 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use Object.keys(data).length > 0 to test for existence of data.","message":"getLegacyData() 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For WKWebView data persistence, use standard localStorage or a different migration strategy.","message":"UIWebView is deprecated on iOS; this plugin only supports data migration from UIWebView, not WKWebView. Modern apps on iOS should not rely on UIWebView data.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Check returned data length; if zero, consider alternative migration paths.","message":"On 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2023':50 '7.0.0':45 'access':68 'activ':52 'allow':39 'android':18 'capacitor':1,4,21,70 'capacitor/core':44 'crosswalk':16,25 'data':11 'databas':34 'dep':42 'develop':53 'differenti':56 'file':35 'format':31 'handl':57 'hidden':63 'io':14 'javascript':69 'key':55 'legaci':9 'leveldb':30,61,67 'localstorag':2,10 'migrat':3,8 'modern':20 'nativ':72 'observ':54 'origin':33 'peer':41 'plugin':5,71 'preserv':32 'releas':49 'reliabl':66 'retri':40 'safeti':37 'ship':46 'sqlite':26,59 'support':23 'system':28 'type':48 'typescript':47,73 'uiwebview':13 'use':62 'v1.2.0':6 'webview':17,22,29,64","created_at":"2026-06-07T16:50:24.984203+00:00","updated_at":"2026-06-07T16:50:24.984203+00:00","problems":[{"fix":"Change to: import { LocalStorageMigration } from 'capacitor-localstorage-migration'","cause":"Using a default import instead of the named import.","error":"Error: \"LocalStorageMigration\" is not a constructor"},{"fix":"Guard with platform check: if (Capacitor.isNativePlatform()) { ... }","cause":"Calling getLegacyData() on a non-native platform (e.g., browser).","error":"Uncaught (in promise) Error: Plugin does not exist on this platform"},{"fix":"Run 'npx cap sync' after installing the plugin.","cause":"Plugin not synced with Capacitor (missing npx cap sync) or not installed on the native project.","error":"TypeError: Cannot read properties of undefined (reading 'getLegacyData')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/Chuckv01/capacitor-localstorage-migration#readme","github":"https://github.com/Chuckv01/capacitor-localstorage-migration","docs":null,"changelog":null,"pypi":null,"npm":"capacitor-localstorage-migration","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}