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

@veliovgroup/client-storage

v5.0.0

Published

Bulletproof persistent browser storage with pluggable drivers (localStorage, cookies, in-memory). Full TS support, TTL, Unicode, no deps. Meteor + NPM compatible.

Readme

ClientStorage

[!WARNING] ClientStorage is deprecated on npm. Use @veliovgroup/client-storage going forward.

Bulletproof persistent browser storage. Drivers: localStorage > cookies > js (in-memory). TTL, JSON values (objects/arrays/booleans/null/undefined), Unicode. No deps. Meteor + NPM + full TS support.

support support

Persistent Browser (Client) Storage

  • 👷 100% Tests coverage;
  • 📦 No external dependencies;
  • 💪 Bulletproof persistent Client storage;
  • ㊗️ With Unicode support for values and keys;
  • 👨‍💻 With String, Array, Object, and Boolean support as values;
  • ♿ Works with disabled localStorage and cookies;
  • ☄️ Meteor.js-specific docs
  • 📦 Available via NPM and Atmosphere.

ClientStorage NPM library logo

Install

npm install @veliovgroup/client-storage

Usage

// NPM / TS / ESM
import { ClientStorage } from '@veliovgroup/client-storage';
const storage = new ClientStorage(); // auto or 'localStorage' | 'cookies' | 'js'

Values

Values pass through JSON serialization when stored in persistent drivers.

const storage = new ClientStorage();

storage.set('locale', 'en');
storage.set('user', { id: 1, prefs: { theme: 'dark' } }, 3600);
storage.set('flags', ['beta', 'compact']);
storage.set('enabled', true);
storage.set('empty', null);
storage.set('void', undefined);

storage.get('user');     // { id: 1, prefs: { theme: 'dark' } }
storage.has('void');     // true
storage.get('void');     // undefined
storage.keys();          // non-expired keys

TTL

storage.set('session', 'secret', 30);

storage.get('session'); // 'secret'
// after 30 seconds:
storage.get('session'); // undefined, record removed

Drivers

new ClientStorage();             // auto: localStorage -> cookies -> js
new ClientStorage('localStorage');
new ClientStorage('cookies');
new ClientStorage('js');         // in-memory, per instance

[!IMPORTANT] Multiple instances: Persistent drivers (localStorage/cookies) share data; js has isolated context per each instance. Server-side code uses js because browser storage APIs do not exist there.

API

  • storage.set(key: string, value: any, ttl?: number): boolean — Store. TTL in seconds.
  • storage.get(key: string): any | undefined — Read. Auto-removes expired. undefined if missing.
  • storage.has(key: string): boolean — Exists and not expired.
  • storage.remove(key?: string): boolean — Remove key or all (empty).
  • storage.empty(): boolean — Alias for remove(). Caution: clears tracked keys; may affect other cookies if no prefix.
  • storage.keys(): string[] — Current keys.
  • storage.driverName — Active driver.
storage.set(key: string, value: any, ttl?: number): boolean
storage.get(key: string): any
storage.has(key: string): boolean
storage.keys(): string[]
storage.remove(key?: string): boolean
storage.empty(): boolean
storage.driverName: 'localStorage' | 'cookies' | 'js'

TS: Full types included. See index.d.ts. Use with import type { ClientStorage } from '@veliovgroup/client-storage';

  • ttl is seconds.
  • get() and has() remove expired records before returning.
  • keys() returns non-expired keys.
  • remove(key) removes one record.
  • remove() and empty() remove all records known to selected backend.
  • js driver is in-memory and isolated per ClientStorage instance.
  • localStorage and cookies persist across instances on same origin.

[!TIP] Drivers exported: ClientStorage, BaseStorage, BrowserStorage, CookiesStorage, JSStorage.

Examples

const storage = new ClientStorage();

storage.set('locale', 'en');
storage.set('user', { id: 1, prefs: { theme: 'dark' } }, 3600); // 1hr TTL
storage.set('flag', true);

console.log(storage.get('user')); // {id:1, prefs:...}
console.log(storage.has('locale')); // true
console.log(storage.keys()); // ['locale', 'user', 'flag']

storage.remove('locale');
storage.empty(); // clears all

Tests

  • Jest (NPM): npm test — covers API, edges, errors, drivers, BaseStorage.
npm test

100% functional coverage. See client-storage-tests.js, tests/client-storage.test.js.

Support this project