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

browser-storage-utils

v1.0.2

Published

A lightweight utility library for browser storage operations

Readme

Storage Utils

A lightweight, type-safe TypeScript/JavaScript library for handling browser storage with a consistent API across different storage mechanisms.

Features

  • Cookie Storage - Simple cookie management with expiration, domain, and secure options
  • Local Storage - Persistent key-value storage with prefix support
  • Session Storage - Session-based key-value storage with prefix support
  • Type Safety - Built with TypeScript for better developer experience
  • SSR Support - Safe to use in server-side rendering environments
  • Modular - Import only what you need

Installation

npm install storage-utils
# or
yarn add storage-utils

Usage

Importing

// Import specific utilities as needed
import { 
  // Cookie functions
  setCookie, 
  getCookie, 
  removeCookie,
  
  // Local Storage
  getLocalItem,
  setLocalItem,
  removeLocalItem,
  clearLocalStorage,
  getLocalKeys,
  
  // Session Storage
  getSessionItem,
  setSessionItem,
  removeSessionItem,
  clearSessionStorage,
  getSessionKeys
} from 'storage-utils';

Cookie Storage

// Set a cookie
setCookie('theme', 'dark', { 
  expires: 7, // days
  path: '/',
  secure: true,
  sameSite: 'Lax'
});

// Get a cookie
const theme = getCookie('theme'); // 'dark'

// Remove a cookie
removeCookie('theme');

Local Storage

// Set an item with prefix
setLocalItem('user', { name: 'John', id: 1 }, { prefix: 'app_' });

// Get an item
const user = getLocalItem('user', { prefix: 'app_' });

// Get all keys with prefix
const keys = getLocalKeys({ prefix: 'app_' });

// Remove an item
removeLocalItem('user', { prefix: 'app_' });

// Clear all items with prefix
clearLocalStorage({ prefix: 'app_' });

Session Storage

// Set an item with prefix
setSessionItem('token', 'abc123', { prefix: 'auth_' });

// Get an item
const token = getSessionItem('token', { prefix: 'auth_' });

// Clear all session storage
clearSessionStorage();

API Reference

Common Options

All storage methods accept an optional options object that can include:

  • prefix?: string - Optional prefix for key namespacing

Cookie Specific Options

interface CookieOptions {
  expires?: number | Date; // days or Date object
  path?: string;
  domain?: string;
  secure?: boolean;
  sameSite?: 'Strict' | 'Lax' | 'None';
  prefix?: string;
}

Browser Support

This library works in all modern browsers including:

  • Chrome 49+
  • Firefox 44+
  • Safari 10.1+
  • Edge 16+
  • Opera 36+

License

MIT