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

react-mnemonic

v1.5.0

Published

Persistent, type-safe state management for React

Readme

react-mnemonic

AI-friendly, persistent, type-safe state for React.

npm version docs license

react-mnemonic gives your components persistent memory through a hook that feels like useState. Values survive reloads, can stay in sync across tabs, and remain SSR-safe by default. It is designed to be AI-friendly, prioritizing visible structure and unambiguous specifications. When you need more than raw storage, the package can validate, version, and migrate persisted data.

Installation

npm install react-mnemonic

React 18 or later is required.

Quick start

Wrap your app in a MnemonicProvider, then call useMnemonicKey anywhere inside it.

import { MnemonicProvider, useMnemonicKey } from "react-mnemonic/core";

function Counter() {
    const { value: count, set } = useMnemonicKey("count", {
        defaultValue: 0,
    });

    return (
        <div>
            <p>Count: {count}</p>
            <button onClick={() => set((c) => c + 1)}>Increment</button>
        </div>
    );
}

export default function App() {
    return (
        <MnemonicProvider namespace="my-app">
            <Counter />
        </MnemonicProvider>
    );
}

This persists the counter in localStorage as my-app.count, so the value survives a full page reload.

Why use it

  • useState-like API: useMnemonicKey returns { value, set, reset, remove }
  • Namespaced persistence through MnemonicProvider
  • Optional cross-tab synchronization
  • SSR-safe defaults for server-rendered React apps
  • Optional schema validation, versioning, migrations, and reconciliation
  • Zero runtime dependencies with published TypeScript types

Pick the right entrypoint

| Entrypoint | Approx ESM size | Use when | | -------------------------- | --------------- | ----------------------------------------------------------------------------------- | | react-mnemonic/optional | ~4.9 KB | You want the tiny component-library shim that falls back to local memory | | react-mnemonic/bootstrap | ~25 KB | You need synchronous first-paint recall before React renders | | react-mnemonic/core | ~61 KB | A provider is required and you want the lean persisted-state path | | react-mnemonic/schema | ~80.5 KB | A provider is required and you want schema validation, autoschema, and migrations | | react-mnemonic | ~80.5 KB | You want the top-level full entrypoint with the same schema-capable runtime surface |

These are rough current estimates from the built ESM entry files in dist/ before consumer-side minification and tree-shaking. They are useful for relative comparison, not as a hard size guarantee.

Optional persistence for component libraries

If your component may render inside or outside a MnemonicProvider, import the optional hook instead of branching at the call site.

import { useMnemonicKeyOptional } from "react-mnemonic/optional";

function SearchBox() {
    const { value, set, remove } = useMnemonicKeyOptional("draft", {
        defaultValue: "",
    });

    return (
        <div>
            <input value={value} onChange={(event) => set(event.target.value)} />
            <button onClick={remove}>Clear</button>
        </div>
    );
}

Inside a provider, the draft is persisted. Outside a provider, the same hook behaves like local in-memory state without throwing.

The lean optional entrypoint exports only:

  • useMnemonicKeyOptional(...)
  • useMnemonicOptional()
  • defineMnemonicKey(...)

Schema metadata such as schema: { version } can still be passed through the optional hook. Applications pay the schema/runtime cost only when they mount a schema-capable MnemonicProvider.

AI resources

| Resource | Purpose | | ------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | | AI Docs | Canonical invariants, decision matrix, recipes, anti-patterns, and setup guidance | | llms.txt | Compact retrieval index for tight context windows | | llms-full.txt | Long-form export for indexing and larger prompt contexts | | ai-contract.json | Machine-readable persistence contract for tooling and agent integrations | | DeepWiki priorities | Steering file that points DeepWiki toward the highest-signal sources | | AI Assistant Setup | Generated instruction packs plus the documented MCP-friendly retrieval path |

Learn more

License

MIT