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

@byburri/locsess-storage-helper

v0.1.2

Published

Browser storage helper

Downloads

30

Readme

@byburri/locsess-storage-helper

npm version npm downloads license

A lightweight TypeScript library for working with localStorage and sessionStorage with built-in key prefixing and TTL cache.


Features

  • Safe localStorage / sessionStorage access with availability checks
  • Automatic key prefixing
  • TTL cache support (expires items automatically)
  • clear() only removes keys created by the library
  • Fully typed with TypeScript

Installation

    # npm
    npm install @byburri/locsess-storage-helper
    # yarn
    yarn add @byburri/locsess-storage-helper

API

createLocalStorage(prefix?: string): LocalStorageApi - creates a localStorage wrapper with an optional key prefix.

Example:

import { createLocalStorage } from "@byburri/locsess-storage-helper";

const storage = createLocalStorage("myapp");

storage.set("token", "123");
console.log(storage.get("token")); // "123"

storage.remove("token");

storage.clear(); // removes all keys starting with "myapp-"

createSessionStorage(prefix?: string): SessionStorageApi - same as createLocalStorage, but uses sessionStorage instead.

Example:

import { createSessionStorage } from "@byburri/locsess-storage-helper";

const storage = createSessionStorage("myapp");

storage.set("token", "123");
console.log(storage.get("token")); // "123"

storage.remove("token");

storage.clear(); // removes all keys starting with "myapp-"

Methods

Local Storage

get(key) - Get the value for a key

set(key, value) - Set a value for a key

remove(key) - Remove a key

clear() - Remove all keys with the current prefix

Cache (TTL)

Supports caching with automatic expiration.

const storage = createLocalStorage("myapp");

// Store user object for 10 minutes
storage.cacheSet("user", { name: "Denys" }, 1000 * 60 * 10);

const user = storage.cacheGet("user"); // returns the cached value

storage.cacheRemove("user"); // remove a cached key

storage.cacheFlushExpired(); // removes all expired cache entries

Key Prefixes

By default, the library uses the prefix: locsess-

You can provide a custom prefix:

const storage = createLocalStorage("myapp");

All keys will be stored as:

myapp:key

This helps to avoid collisions with other localStorage or sessionStorage keys.

TypeScript Usage

The package is fully typed. You can use ReturnType to get API types:

import { createLocalStorage } from "@byburri/locsess-storage-helper";

type LocalStorageApi = ReturnType<typeof createLocalStorage>;
type SessionStorageApi = ReturnType<typeof createSessionStorage>;

const storage: LocalStorageApi = createLocalStorage("myapp");

Generic support

const storage = createLocalStorage("myapp");

storage.set("count", 10);
const count = storage.get<number>("count");