Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@mrravipandee/localstorage-js

mrravipandee0MIT1.1.0

A lightweight utility to simplify working with localStorage in JavaScript. Includes expiry, backup/restore, and debug helpers.

localstorage, storage, browser-storage, local-storage-helper, javascript, expiry-storage, js-helper, web-storage, storage-utils, storage-backup, local-storage-json, localstorage-expiry, react-storage, angular-storage, vue-storage, vanilla-js, data-store, localstorage-wrapper, browser-cache, persistent-storage, javascript-utility, storage-api, auto-expire, json-storage, cache-manager, frontend-toolkit, session-storage, key-value-store, dev-tools, react-helper, angular-helper, vue-helper, modular-js, tiny-storage, storage-helpers, state-management, cookie-alternative, storage-utility, browser-tools, simple-storage, storage-extension, npm-package, storage-module, use-localstorage, js-library, vanilla-js-tool, storage-lib, storage-utils-js, debug-tools, developer-tools, js-expiry, key-expiry, time-based-expiry, data-management, web-dev-tools, offline-storage, backup-storage, restore-data, browser-utils, tiny-lib, custom-storage, auto-expire-store, minimal-storage, js-storage-manager, frontend-utils, simple-js-library, tiny-js-lib, quick-storage, browser-key-store, easy-storage, expiry-manager, quick-backup, minimal-library, frontend-helper, toolkit-js, javascript-storage, npm-storage, storage-simplified, smart-storage, session-manager, state-helper, js-helpers, storage-fallback, cache-helper

readme

localstorage-js

A lightweight and powerful JavaScript utility for handling localStorage operations with ease. It supports data expiry, backup/restore, and includes debug tools to simplify development. Works with Vanilla JS, React, Next.js, Vue, Angular, and more.


🚀 Features

  • Simple set and get methods
  • Expiry support (auto-remove items after time)
  • Backup & restore storage data
  • Debug logging for development
  • Works with all JavaScript frameworks
  • Zero dependencies

📦 Installation

npm install localstorage-js

📚 Usage

Basic Usage (Vanilla JS / ES Module)

import { storage } from 'localstorage-js';

// Set and Get
storage.setItem('user', { name: 'Ravi', role: 'Developer' });
console.log(storage.getItem('user'));

Expiry Support

// Store with 1-minute expiry
storage.setWithExpiry('session', 'abc123', 1);
console.log(storage.getWithExpiry('session'));

Backup & Restore

const backup = storage.backup();
storage.clear();
storage.restore(backup);

Debugging

storage.debugSet('email', 'imravipanday@gmail.com');
storage.debugGet('email');

🧪 Example (HTML Test)

Create a file test.html:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Test LocalStorage</title>
  </head>
  <body>
    <h2>Check Console for Output</h2>
    <script type="module">
      import { storage } from '../src/index.js';

      storage.setItem('user', { name: 'Ravi', role: 'Dev' });
      console.log('User:', storage.getItem('user'));

      storage.setWithExpiry('session', 'abc123', 1);
      console.log('Session:', storage.getWithExpiry('session'));

      const backup = storage.backup();
      console.log('Backup:', backup);

      storage.clear();
      console.log('After clear:', storage.getItem('user'));

      storage.restore(backup);
      console.log('Restored:', storage.getItem('user'));

      storage.debugSet('email', 'imravipanday@gmail.com');
      storage.debugGet('email');
    </script>
  </body>
</html>

🛠 Tech Stack

  • JavaScript (ES6)
  • LocalStorage API

✍ Author

Ravi Pandey
Web: https://imravidev.vercel.app
Email: imravipanday@gmail.com


📦 GitHub Repo

https://github.com/mrravipandee/node-packages/tree/main/localstorage-js


🔒 License

MIT License