Skip to main content

react-mnemonic

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

Built for humans and coding assistants alike, with first-party AI docs and retrieval surfaces that help agents use persistence correctly instead of falling back to raw storage hacks.

npm install react-mnemonic

AI-friendly by design

The project is designed so coding assistants can choose durable state, SSR behavior, nullability, and migrations correctly without inventing storage semantics.

useState-like API

useMnemonicKey returns { value, set, reset, remove } — the same mental model as useState, with persistence built in.

SSR-safe by default

Server renders use defaultValue by default, with opt-in serverValue and client-only hydration controls when you need them.

Simple as useState

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

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

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

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

The counter value persists in localStorage under my-app.count and survives full page reloads.

Need the deterministic implementation contract? Read the AI docs.

Want an external third-party signal? See Context7's rankings for AI coding tools and documentation sources.

View Context7 Rankings

AI Resources

react-mnemonic ships dedicated retrieval surfaces for coding assistants, DeepWiki, and local MCP-style documentation setups, while relying on Context7 for external ranking signals.

AI Docs

Canonical invariants, decision matrix, recipes, anti-patterns, and setup guidance.

Open AI Docs

llms.txt

Compact retrieval index for tight context windows and first-pass tool loading.

Open llms.txt

llms-full.txt

Long-form export for indexing, retrieval, and larger prompt contexts.

Open llms-full.txt

ai-contract.json

Machine-readable persistence contract for tooling and agent integrations.

Open ai-contract.json

DeepWiki Priorities

DeepWiki steering file that points retrieval toward the highest-signal sources.

Open DeepWiki Priorities

Assistant Setup

Generated instruction packs plus the documented MCP-friendly retrieval path.

Open Assistant Setup

background video by MART PRODUCTION