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

@nullvector/simplestore

v1.0.0

Published

Beginner-friendly, cross-platform local storage abstraction for Web and React Native

Readme

SimpleStore

One small async key-value API for Web, React Native and Expo. Values are stored as JSON; each platform's storage engine sits behind an adapter.

npm install @dipu01-code/simplestore
# React Native / Expo also need:
npm install @react-native-async-storage/async-storage

Quick start

// Web (localStorage)
import { storage } from "@dipu01-code/simplestore/web";
// React Native / Expo (AsyncStorage)
import { storage } from "@dipu01-code/simplestore/react-native";

await storage.set("username", "Dipu");
await storage.set("profile", { name: "Dipu", course: "AI & ML" });

const username = await storage.get<string>("username"); // "Dipu"
const profile = await storage.get<{ name: string; course: string }>("profile");

await storage.has("profile"); // true
await storage.keys();         // ["username", "profile"]
await storage.remove("username");
await storage.clear();

Entry points

| Import | Exports | Needs | | ---------------------------------------- | -------------------------------------------------------------- | ------------------------------------------- | | @dipu01-code/simplestore | createStorage, memoryAdapter, SimpleStoreError, types | nothing | | @dipu01-code/simplestore/web | everything above + storage (localStorage), webAdapter | a browser (safe to import during SSR) | | @dipu01-code/simplestore/react-native | everything above + storage (AsyncStorage), asyncStorageAdapter | @react-native-async-storage/async-storage | | @dipu01-code/simplestore/react | useStorage hook | react ≥ 16.8 |

The web entry never loads AsyncStorage, and only /react loads React.

API

All methods are async.

| Method | Returns | Notes | | --------------------- | --------------------------- | -------------------------------------------------------- | | set(key, value) | void | value must be JSON-serializable | | get<T>(key) | T \| undefined | undefined when the key is missing | | has(key) | boolean | | | remove(key) | void | No-op if missing | | keys() | string[] | Requires the adapter to implement getAllKeys | | clear() | void | See Namespaces | | multiSet(entries) | void | [[key, value], ...]; all entries validated before any write | | multiGet<T>(keys) | { key, value }[] | |

Custom setup

import { createStorage, memoryAdapter } from "@dipu01-code/simplestore";
import { webAdapter } from "@dipu01-code/simplestore/web";

const session = createStorage({ adapter: webAdapter("session") }); // sessionStorage
const testStore = createStorage({ adapter: memoryAdapter() });      // tests / SSR

Namespaces & what clear() deletes

Without a prefix, clear() wipes the entire underlying store (all of localStorage / AsyncStorage, including other libraries' data). Pass a prefix to isolate your data:

const appStore = createStorage({ adapter: webAdapter(), prefix: "myapp:" });
await appStore.set("user", "Dipu"); // stored as "myapp:user"
await appStore.keys();              // ["user"]
await appStore.clear();             // removes only "myapp:*" keys

Custom adapters

Implement this interface (getAllKeys is optional, but keys() and prefixed clear() need it):

interface StorageAdapter {
  getItem(key: string): Promise<string | null>;
  setItem(key: string, value: string): Promise<void>;
  removeItem(key: string): Promise<void>;
  clear(): Promise<void>;
  getAllKeys?(): Promise<string[]>;
}

React hook

import { storage } from "@dipu01-code/simplestore/web";
import { useStorage } from "@dipu01-code/simplestore/react";

function Counter() {
  const { value, set, remove, loading, error } = useStorage<number>(storage, "count", 0);
  if (loading) return null;
  return <button onClick={() => set((value ?? 0) + 1)}>{value}</button>;
}

initialValue is shown while loading and when the key is missing; it is not written to storage. Two components using the same key do not sync with each other automatically.

Errors

Every failure is thrown (never swallowed) as a SimpleStoreError with a code, and original holds the underlying error when there is one:

| Code | When | | --------------------- | ------------------------------------------------------------ | | INVALID_KEY | Key is not a non-empty string | | UNSUPPORTED_VALUE | undefined, function, symbol or bigint | | SERIALIZATION_ERROR | JSON.stringify failed (e.g. circular object) | | MALFORMED_DATA | Stored value isn't valid JSON (written outside SimpleStore) | | QUOTA_EXCEEDED | Storage is full | | STORAGE_UNAVAILABLE | No storage (SSR, blocked by privacy settings) | | UNKNOWN_ERROR | Anything else |

import { SimpleStoreError } from "@dipu01-code/simplestore";
try {
  await storage.set("big", hugeObject);
} catch (e) {
  if (e instanceof SimpleStoreError && e.code === "QUOTA_EXCEEDED") { /* ... */ }
}

SSR (Next.js, Remix, …)

Importing /web on the server is safe. Without window, reads return undefined / [] and writes throw STORAGE_UNAVAILABLE. On the server, use memoryAdapter() instead, or only call storage in effects/client code.

Security

localStorage, sessionStorage and AsyncStorage are not encrypted and any script on the page (or anyone with device access) can read them. Don't store passwords, auth tokens or other secrets here; use expo-secure-store, Keychain/Keystore, or httpOnly cookies instead.

Development

npm install
npm run lint && npm run typecheck && npm test && npm run build

License

MIT