npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

capacitor-localstorage-migration

v1.2.0

Published

Migration of legacy localStorage data from legacy web views on Android and iOS.

Readme

Capacitor LocalStorage Migration Plugin

A Capacitor plugin designed to help migrate legacy web storage data from UIWebView (iOS) and Crosswalk WebView (Android) to modern WebView implementations.

When 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.

Key features:

  • Retrieves localStorage data from legacy WebViews
  • Supports both Crosswalk SQLite and System WebView LevelDB formats (Android)
  • Preserves original database files for safety
  • Supports both iOS (UIWebView) and Android (Crosswalk) platforms
  • Enables smooth app transitions without data loss

The plugin maintains the original storage files as a fallback, allowing multiple migration attempts if needed.

Installation

npm install capacitor-localstorage-migration
npx cap sync

Usage

import { LocalStorageMigration } from 'capacitor-localstorage-migration';

async function migrateLocalStorage() {
  try {
    // Check if migration was already completed
    if (localStorage.getItem('migrationCompleted')) {
      console.log('Migration was already completed');
      return true;
    }

    const data = await LocalStorageMigration.getLegacyData();
    
    if (data && Object.keys(data).length > 0) {
      // Do something with the legacy data!
      console.log(data);

      // Example: Copy legacy localStorage to current localStorage
      Object.entries(data).forEach(([key, value]) => {
        localStorage.setItem(key, value);
      });

      // Mark migration as completed
      localStorage.setItem('migrationCompleted', 'true');
      return true;
    } else {
      // If no legacy data found, mark migration completed to avoid future runs
      localStorage.setItem('migrationCompleted', 'true');
      console.log('No legacy data found');
      return false;
    }
  } catch (err) {
    console.error('Error during localStorage migration:', err);
    return false;
  }
}

API

getLegacyData()

getLegacyData() => Promise<{ [key: string]: any; }>

Returns: Promise<{ [key: string]: any; }>


Supported Platforms

  • Android
    • Crosswalk SQLite storage (primary)
      • Path: /data/data/[package-name]/app_xwalkcore/Default/Local Storage/file__0.localstorage
      • Handles UTF-16LE encoding
    • System WebView LevelDB storage (fallback)
      • Path: /data/data/[package-name]/app_webview/Default/Local Storage/leveldb/
      • Supports apps that used cordova-plugin-crosswalk-data-migration to move data from Crosswalk to the system WebView
      • Correctly handles LevelDB's append-only format by reading the most recent value for each key
  • iOS
    • Retrieves data from UIWebView localStorage
    • Path: [Library]/WebKit/LocalStorage/file__0.localstorage

Android LevelDB Support

If 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:

  1. First checks for Crosswalk SQLite storage
  2. Falls back to system WebView LevelDB storage if Crosswalk storage is not found

The LevelDB reading uses a hidden WebView to reliably access the legacy localStorage:

  • Creates a temporary WebView that loads a file:// URL
  • This gives access to the legacy localStorage data stored under the file:// origin
  • Uses JavaScript to read all localStorage keys and values
  • Works across all Android versions and device manufacturers
  • 100% reliable since it uses the WebView's own localStorage implementation

Error Handling

The plugin includes comprehensive error handling for common scenarios:

  • Database not found
  • SQLite reading errors
  • Data decoding issues
  • Memory constraints

Errors are returned as rejected promises with descriptive messages.

Requirements

  • Capacitor 7.0.0 or higher
  • iOS 13.0 or higher
  • Android API 23 or higher

Development

Building

npm run build

Running Tests

npm test

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.