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

@milandadhaniya/local-storage-hook

v1.0.2

Published

Typed and logger-integrated localStorage utility

Readme

@milandadhaniya/local-storage-hook

A simple and typed utility for interacting with localStorage in the browser using TypeScript. Built-in support for structured key-value storage, nested field manipulation, custom event dispatching, and optional logging using @milandadhaniya/tiny-logger-js.


📦 Installation

npm install @milandadhaniya/local-storage-hook

📚 API

import {
  setItem,
  getItem,
  removeItem,
  clearStorage
} from '@milandadhaniya/local-storage-hook';

🧪 Usage Examples

setItem

Sets a value in localStorage. Returns true if successful, false otherwise.

// Set a raw value
setItem('AppSettings', null, {
  themeOptions: ['dark', 'light'],
  language: 'en',
  notifications: {
    enabled: true,
    sound: true,
    vibration: false
  },
  font: {
    family: 'Arial'
  }
});

// Set an object field
setItem('AppSettings', 'font', {
  size: '16px',
  family: 'Arial'
});

// Enable logging (Default: false)
setItem('SelectedTheme', null, 'dark', true);

📥 getItem

Retrieves a value from localStorage. Returns the requested value or undefined if not found.

// Get the raw value
const raw = getItem('AppSettings');

// Get nested field from object
const notifications = getItem('AppSettings', 'notifications');

🗑️ removeItem

Removes an item from localStorage. Returns true if successful, false otherwise.

// Remove specific field from an object (Enable logging)
removeItem('AppSettings', 'font', true);

// Remove the full key
removeItem('AppSettings');

🧹 clearStorage

Clears all items from localStorage. Returns true if successful, false otherwise.

// Clear everything
clearStorage();

// With logging
clearStorage(true);

🎧 Listen for Changes

const handler = (e: CustomEvent) => {
  console.log('Storage event fired:', e.detail);
};

window.addEventListener('local-storage-change', handler);

// Later, to clean up
window.removeEventListener('local-storage-change', handler);

📄 License

MIT License — © 2025 Milan Dadhaniya