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

@jayoncode/storage

v0.4.2

Published

Storage — Namespace it. Expire it. Upgrade it — without localStorage glue. Explicit adapters (memory / localStorage / sessionStorage / IndexedDB), TTL, migrations.

Readme

Storage — Typed, framework-agnostic client-side storage for modern web apps.

Namespace it. Expire it. Upgrade it — without localStorage glue.

@jayoncode/storage — policy-driven client persistence for modern web apps.

npm version license docs Become a Sponsor

A small policy layer for browser persistence — namespaces, envelopes, TTL, migrations — on adapters you choose: memory, localStorage, sessionStorage, and IndexedDB.

Explicit adapters. Optional policy.
Soft quota and transforms hooks are opt-in — no silent encryption.

Persist → Policy → Adapt

createStorage({ namespace, adapter })
    ↓
TTL · schema version · migrations (optional)
    ↓
peek · quota · transforms · maintenance (optional)

| Pillar | What you get | | ----------- | ---------------------------------------------------------------------- | | Persist | Typed set / get with namespaced keys | | Policy | TTL, schema version, migrations, soft quota | | Adapt | Memory · localStorage · sessionStorage · IndexedDB — never auto-picked |

Five capabilities

| Card | What it is | | --------------------- | --------------------------------------------------- | | createStorage() | Namespace + adapter + optional TTL / schema version | | Explicit adapters | Memory · localStorage · sessionStorage · IndexedDB | | Peek & TTL | See when a value was saved and when it expires | | Migrations | Schema upgrades without ad-hoc key rewrites | | Extra tools | Soft quota, transforms hooks, maintenance — opt-in |

Install

npm install @jayoncode/storage
pnpm add @jayoncode/storage
yarn add @jayoncode/storage

The problem it solves

Most apps slowly accumulate helpers like this:

const raw = localStorage.getItem("app:theme");
const parsed = raw ? JSON.parse(raw) : null;
// + manual expiry · version bumps · migration · quota try/catch · per-project key rules

@jayoncode/storage replaces that sprawl with a namespaced, envelope-backed store you configure once.

Quick start — prefs that survive reload

import { createStorage, createLocalStorageAdapter } from "@jayoncode/storage";

const storage = createStorage({
  namespace: "app",
  adapter: createLocalStorageAdapter(), // or createMemoryAdapter() / createSessionStorageAdapter()
  ttl: { hours: 1 },
  schemaVersion: "1",
});

storage.set("theme", "dark");
storage.get("theme"); // "dark" | null

Adapters are explicit — the library never chooses a backend for you.

More problem → solution snippets

Named TTL policies

import { createStorage, createLocalStorageAdapter } from "@jayoncode/storage";

const storage = createStorage({
  namespace: "app",
  adapter: createLocalStorageAdapter(),
  policies: {
    preferences: { ttl: { days: 365 } },
    cache: { ttl: { minutes: 15 } },
  },
});

storage.set("theme", "dark", { policy: "preferences" });

TTL resolution: per-write ttl → named policy → instance ttl.

Async IndexedDB

import { createAsyncStorage, createIndexedDbAdapter } from "@jayoncode/storage/async";

const storage = createAsyncStorage({
  namespace: "app",
  adapter: createIndexedDbAdapter(), // default DB: jayoncode-storage
});

await storage.set("theme", "dark");

Cross-tab notify (no auto-merge)

import { enableCrossTabSync } from "@jayoncode/storage/cross-tab";

const { storage: synced, stop } = enableCrossTabSync(storage, {
  onRemote: () => refreshUi(),
});

Soft quota (approx bytes)

import { enableQuotaGuard } from "@jayoncode/storage/quota";

const { storage: guarded } = enableQuotaGuard(storage, {
  maxApproxBytes: 50_000,
});

Opt-in compress / encrypt hooks

import {
  createStorage,
  createMemoryAdapter,
  defaultSerialize,
  defaultDeserialize,
} from "@jayoncode/storage";
import { withPayloadTransforms } from "@jayoncode/storage/transforms";

const { serialize, deserialize } = withPayloadTransforms(
  { serialize: defaultSerialize, deserialize: defaultDeserialize },
  {
    // App-owned sync string → string hooks (Storage does not ship crypto algorithms)
    compress: (plain) => plain,
    decompress: (wire) => wire,
    encrypt: (plain) => plain,
    decrypt: (wire) => wire,
  },
);

const storage = createStorage({
  namespace: "app",
  adapter: createMemoryAdapter(),
  serialize,
  deserialize,
});

Capabilities (pay only when you import)

| Import | What it solves | | --------------------------------- | ----------------------------------------------------------- | | @jayoncode/storage | Sync createStorage, adapters, errors, default ser/de | | @jayoncode/storage/async | Promise API + IndexedDB adapter | | @jayoncode/storage/cross-tab | Notify other tabs (BroadcastChannel + optional storage) | | @jayoncode/storage/quota | Soft max / warn on approx namespace bytes | | @jayoncode/storage/transforms | Compose compress/encrypt around serialize | | @jayoncode/storage/maintenance | Explicit expired-key cleanup | | @jayoncode/storage/snapshots | Export / restore a namespace | | @jayoncode/storage/observable | In-process on / watch | | @jayoncode/storage/diagnostics | DEV report / activity | | @jayoncode/storage/transactions | Same-tab journal + rollback |

Non-goals

  • Does not own Form Intelligence drafts (keep IDB DBs separate: jayoncode-storage vs jayoncode-form-intelligent-drafts)
  • Does not auto-select storage backends
  • Cross-tab does not auto-merge remote values (notify-only)
  • Soft quota uses approx payload bytes — not exact browser remaining space
  • Does not ship silent encryption/compression or crypto algorithms — opt-in /transforms hooks only; keys stay app-owned

Documentation

Repository

https://github.com/itsjayoncode/joc · Package path: packages/storage

License

MIT © JayOnCode