{"id":26047663,"url":"https://github.com/chuckv01/capacitor-localstorage-migration","last_synced_at":"2026-02-16T18:35:03.122Z","repository":{"id":280704970,"uuid":"942786163","full_name":"Chuckv01/capacitor-localstorage-migration","owner":"Chuckv01","description":"A Capacitor plugin designed to help migrate legacy web storage data from UIWebView (iOS) and Crosswalk WebView (Android) to modern WebView implementations.","archived":false,"fork":false,"pushed_at":"2025-03-07T18:16:46.000Z","size":387,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-23T03:24:40.337Z","etag":null,"topics":["android","capacitor","capacitor-plugin","ios","migration","plugin","uiwebview","wkwebview"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Chuckv01.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-04T17:10:30.000Z","updated_at":"2025-03-07T18:16:05.000Z","dependencies_parsed_at":"2025-03-04T21:42:09.097Z","dependency_job_id":"75bb4f5a-f58a-4d55-8453-d3c1627590bd","html_url":"https://github.com/Chuckv01/capacitor-localstorage-migration","commit_stats":null,"previous_names":["chuckv01/capacitor-localstorage-migration"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Chuckv01/capacitor-localstorage-migration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chuckv01%2Fcapacitor-localstorage-migration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chuckv01%2Fcapacitor-localstorage-migration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chuckv01%2Fcapacitor-localstorage-migration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chuckv01%2Fcapacitor-localstorage-migration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Chuckv01","download_url":"https://codeload.github.com/Chuckv01/capacitor-localstorage-migration/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chuckv01%2Fcapacitor-localstorage-migration/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278614458,"owners_count":26015967,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","capacitor","capacitor-plugin","ios","migration","plugin","uiwebview","wkwebview"],"created_at":"2025-03-07T23:12:48.575Z","updated_at":"2026-02-16T18:35:03.105Z","avatar_url":"https://github.com/Chuckv01.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Capacitor LocalStorage Migration Plugin\n\nA Capacitor plugin designed to help migrate legacy web storage data from UIWebView (iOS) and Crosswalk WebView (Android) to modern WebView implementations.\n\nWhen transitioning from older hybrid mobile apps to Capacitor, local storage data can become inaccessible due to WebView changes. This plugin provides a safe way to retrieve that data, ensuring no user information is lost during the upgrade process.\n\nKey features:\n\n- Retrieves localStorage data from legacy WebViews\n- **Supports both Crosswalk SQLite and System WebView LevelDB formats (Android)**\n- Preserves original database files for safety\n- Supports both iOS (UIWebView) and Android (Crosswalk) platforms\n- Enables smooth app transitions without data loss\n\nThe plugin maintains the original storage files as a fallback, allowing multiple migration attempts if needed.\n\n## Installation\n\n```bash\nnpm install capacitor-localstorage-migration\nnpx cap sync\n```\n\n## Usage\n\n```typescript\nimport { LocalStorageMigration } from 'capacitor-localstorage-migration';\n\nasync function migrateLocalStorage() {\n  try {\n    // Check if migration was already completed\n    if (localStorage.getItem('migrationCompleted')) {\n      console.log('Migration was already completed');\n      return true;\n    }\n\n    const data = await LocalStorageMigration.getLegacyData();\n    \n    if (data \u0026\u0026 Object.keys(data).length \u003e 0) {\n      // Do something with the legacy data!\n      console.log(data);\n\n      // Example: Copy legacy localStorage to current localStorage\n      Object.entries(data).forEach(([key, value]) =\u003e {\n        localStorage.setItem(key, value);\n      });\n\n      // Mark migration as completed\n      localStorage.setItem('migrationCompleted', 'true');\n      return true;\n    } else {\n      // If no legacy data found, mark migration completed to avoid future runs\n      localStorage.setItem('migrationCompleted', 'true');\n      console.log('No legacy data found');\n      return false;\n    }\n  } catch (err) {\n    console.error('Error during localStorage migration:', err);\n    return false;\n  }\n}\n```\n\n## API\n\n\u003cdocgen-index\u003e\n\n* [`getLegacyData()`](#getlegacydata)\n\n\u003c/docgen-index\u003e\n\n\u003cdocgen-api\u003e\n\u003c!--Update the source file JSDoc comments and rerun docgen to update the docs below--\u003e\n\n### getLegacyData()\n\n```typescript\ngetLegacyData() =\u003e Promise\u003c{ [key: string]: any; }\u003e\n```\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;{ [key: string]: any; }\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\u003c/docgen-api\u003e\n\n## Supported Platforms\n\n- Android\n  - **Crosswalk SQLite storage** (primary)\n    - Path: `/data/data/[package-name]/app_xwalkcore/Default/Local Storage/file__0.localstorage`\n    - Handles UTF-16LE encoding\n  - **System WebView LevelDB storage** (fallback)\n    - Path: `/data/data/[package-name]/app_webview/Default/Local Storage/leveldb/`\n    - Supports apps that used `cordova-plugin-crosswalk-data-migration` to move data from Crosswalk to the system WebView\n    - Correctly handles LevelDB's append-only format by reading the most recent value for each key\n  \n- iOS\n  - Retrieves data from UIWebView localStorage\n  - Path: `[Library]/WebKit/LocalStorage/file__0.localstorage`\n\n## Android LevelDB Support\n\nIf your old Cordova app used `cordova-plugin-crosswalk-data-migration`, the data may have been moved from the Crosswalk location to the system WebView's LevelDB storage. This plugin automatically checks both locations:\n\n1. First checks for Crosswalk SQLite storage\n2. Falls back to system WebView LevelDB storage if Crosswalk storage is not found\n\nThe LevelDB reading uses a hidden WebView to reliably access the legacy localStorage:\n- Creates a temporary WebView that loads a `file://` URL\n- This gives access to the legacy localStorage data stored under the `file://` origin\n- Uses JavaScript to read all localStorage keys and values\n- Works across all Android versions and device manufacturers\n- 100% reliable since it uses the WebView's own localStorage implementation\n\n## Error Handling\n\nThe plugin includes comprehensive error handling for common scenarios:\n\n- Database not found\n- SQLite reading errors\n- Data decoding issues\n- Memory constraints\n\nErrors are returned as rejected promises with descriptive messages.\n\n## Requirements\n\n- Capacitor 7.0.0 or higher\n- iOS 13.0 or higher\n- Android API 23 or higher\n\n## Development\n\n### Building\n\n```bash\nnpm run build\n```\n\n### Running Tests\n\n```bash\nnpm test\n```\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchuckv01%2Fcapacitor-localstorage-migration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchuckv01%2Fcapacitor-localstorage-migration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchuckv01%2Fcapacitor-localstorage-migration/lists"}