{"_id":"@asudbury/use-local-storage","_rev":"3-adf5040e21bfdfdc1242212f5c3f2ea1","name":"@asudbury/use-local-storage","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@asudbury/use-local-storage","version":"1.0.0","keywords":["react","hooks","localStorage","typescript","storage","local","state-management","serialization"],"author":{"name":"Your Name"},"license":"MIT","_id":"@asudbury/use-local-storage@1.0.0","maintainers":[{"name":"asudbury","email":"sudburya@gmail.com"}],"homepage":"https://asudbury.github.io/use-local-storage","bugs":{"url":"https://github.com/your-username/use-local-storage/issues"},"dist":{"shasum":"69d2b4376ab32895ee90c78ed0b8e2336fb1a288","tarball":"https://registry.npmjs.org/@asudbury/use-local-storage/-/use-local-storage-1.0.0.tgz","fileCount":9,"integrity":"sha512-glzYl3e5Q8whwzBZhbGOzLlqkPH7qMr2IfJ8kchneSgTl36pgGvme8gDcUnzsywphKEcs8byTNje4/Ffe3uUzA==","signatures":[{"sig":"MEUCIQC/5nBz6e8zOTVX+MbFZqb4ZCXETO19QoNrmuyetbDxUgIgN6h1X76ZIVZTZBZDzH3lvW1F9x1gqJ+oXKnMuVNiJ4c=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":49237},"main":"dist/index.cjs.js","types":"dist/index.d.ts","module":"dist/index.esm.js","engines":{"node":">=14.0.0"},"gitHead":"5b4f25b1c74be75fa102af0349f72b026d90a6db","scripts":{"lint":"eslint src --ext .ts,.tsx","test":"vitest run","build":"tsc","format":"prettier --write src/**/*.{ts,tsx}","analyze":"node scripts/analyze-bundle.js","prepare":"npm run build","release":"npm run test && npm run lint && npm run build && npm run analyze","lint:fix":"eslint src --ext .ts,.tsx --fix","storybook":"storybook dev -p 6006","docs:build":"npm run docs:generate","test:watch":"vitest","format:check":"prettier --check src/**/*.{ts,tsx}","docs:generate":"node scripts/generate-docs.js","docs:markdown":"jsdoc2md --files src/useLocalStorage.ts > docs/api.md","test:coverage":"vitest run --coverage","prepublishOnly":"npm run build","build-storybook":"storybook build","deploy:storybook":"npm run build-storybook:gh-pages && gh-pages -d storybook-static","preview-storybook":"npx http-server storybook-static -p 8080 -o","storybook:publish":"npm run build-storybook && gh-pages -d storybook-static","build-storybook:gh-pages":"storybook build --output-dir storybook-static"},"_npmUser":{"name":"asudbury","email":"sudburya@gmail.com"},"repository":{"url":"git+https://github.com/your-username/use-local-storage.git","type":"git"},"_npmVersion":"11.6.2","description":"A powerful React hook for LocalStorage management with TypeScript support, serialization, and comprehensive event handling","directories":{},"_nodeVersion":"22.20.0","browserslist":{"production":[">0.2%","not dead","not op_mini all"],"development":["last 1 chrome version","last 1 firefox version","last 1 safari version"]},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","vite":"^4.5.0","husky":"^8.0.0","react":"^18.2.0","eslint":"^8.57.1","vitest":"^3.2.4","gh-pages":"^6.3.0","react-dom":"^18.2.0","storybook":"^7.5.0","typescript":"^5.8.3","@babel/core":"^7.23.0","@types/jest":"^29.5.0","@types/react":"^18.2.0","eslint-plugin-n":"^16.6.2","vite-plugin-dts":"^3.9.1","@storybook/react":"^7.5.0","@types/react-dom":"^18.2.0","@babel/preset-env":"^7.23.0","@storybook/blocks":"^7.5.0","jsdoc-to-markdown":"^9.1.1","@babel/preset-react":"^7.22.0","eslint-plugin-react":"^7.37.5","eslint-plugin-import":"^2.32.0","@storybook/react-vite":"^7.5.0","eslint-plugin-promise":"^6.6.0","@storybook/addon-links":"^7.5.0","@testing-library/react":"^13.4.0","jest-environment-jsdom":"^29.7.0","eslint-plugin-storybook":"^0.6.0","@babel/preset-typescript":"^7.23.0","@storybook/addon-actions":"^7.5.0","@testing-library/jest-dom":"^6.1.0","@typescript-eslint/parser":"^6.0.0","eslint-plugin-react-hooks":"^4.6.0","@storybook/testing-library":"^0.2.0","@storybook/addon-essentials":"^7.5.0","@testing-library/user-event":"^14.5.0","@storybook/addon-interactions":"^7.5.0","@typescript-eslint/eslint-plugin":"^6.21.0","eslint-config-standard-with-typescript":"^43.0.1"},"peerDependencies":{"react":">=16.8.0","react-dom":">=16.8.0"},"_npmOperationalInternal":{"tmp":"tmp/use-local-storage_1.0.0_1766396644743_0.8059824042417039","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@asudbury/use-local-storage","version":"1.0.1","keywords":["react","hooks","localStorage","typescript","storage","local","state-management","serialization"],"author":{"name":"Your Name"},"license":"MIT","_id":"@asudbury/use-local-storage@1.0.1","maintainers":[{"name":"asudbury","email":"sudburya@gmail.com"}],"homepage":"https://asudbury.github.io/use-local-storage","bugs":{"url":"https://github.com/asudbury/use-local-storage/issues"},"dist":{"shasum":"f0ad6d94365b8d46660a023108d97733ba1b771c","tarball":"https://registry.npmjs.org/@asudbury/use-local-storage/-/use-local-storage-1.0.1.tgz","fileCount":9,"integrity":"sha512-BeW2bF2EdEo1qPPBSBr+yqlBPhYE7/jFp83CJM3vRVjmRJYOGF5nPOw1mmmo1lngMLZ1lw/W8iKf6A/+3KJRmw==","signatures":[{"sig":"MEQCIBGChet/OqK7QcQdc8zPmzDAGRHSSo0USJ/BXQs6RtYrAiA/cP5jIEh2MSAaKrcdifTjrSCviRxDboBpUxNQSeJ7oQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":49227},"main":"dist/index.cjs.js","types":"dist/index.d.ts","module":"dist/index.esm.js","engines":{"node":">=14.0.0"},"gitHead":"5b4f25b1c74be75fa102af0349f72b026d90a6db","scripts":{"lint":"eslint src --ext .ts,.tsx","test":"vitest run","build":"tsc","format":"prettier --write src/**/*.{ts,tsx}","analyze":"node scripts/analyze-bundle.js","prepare":"npm run build","release":"npm run test && npm run lint && npm run build && npm run analyze","lint:fix":"eslint src --ext .ts,.tsx --fix","storybook":"storybook dev -p 6006","docs:build":"npm run docs:generate","test:watch":"vitest","format:check":"prettier --check src/**/*.{ts,tsx}","docs:generate":"node scripts/generate-docs.js","docs:markdown":"jsdoc2md --files src/useLocalStorage.ts > docs/api.md","test:coverage":"vitest run --coverage","prepublishOnly":"npm run build","build-storybook":"storybook build","deploy:storybook":"npm run build-storybook:gh-pages && gh-pages -d storybook-static","preview-storybook":"npx http-server storybook-static -p 8080 -o","storybook:publish":"npm run build-storybook && gh-pages -d storybook-static","build-storybook:gh-pages":"storybook build --output-dir storybook-static"},"_npmUser":{"name":"asudbury","email":"sudburya@gmail.com"},"repository":{"url":"git+https://github.com/asudbury/use-local-storage.git","type":"git"},"_npmVersion":"11.6.2","description":"A powerful React hook for LocalStorage management with TypeScript support, serialization, and comprehensive event handling","directories":{},"_nodeVersion":"22.20.0","browserslist":{"production":[">0.2%","not dead","not op_mini all"],"development":["last 1 chrome version","last 1 firefox version","last 1 safari version"]},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","vite":"^4.5.0","husky":"^8.0.0","react":"^18.2.0","eslint":"^8.57.1","vitest":"^3.2.4","gh-pages":"^6.3.0","react-dom":"^18.2.0","storybook":"^7.5.0","typescript":"^5.8.3","@babel/core":"^7.23.0","@types/jest":"^29.5.0","@types/react":"^18.2.0","eslint-plugin-n":"^16.6.2","vite-plugin-dts":"^3.9.1","@storybook/react":"^7.5.0","@types/react-dom":"^18.2.0","@babel/preset-env":"^7.23.0","@storybook/blocks":"^7.5.0","jsdoc-to-markdown":"^9.1.1","@babel/preset-react":"^7.22.0","eslint-plugin-react":"^7.37.5","eslint-plugin-import":"^2.32.0","@storybook/react-vite":"^7.5.0","eslint-plugin-promise":"^6.6.0","@storybook/addon-links":"^7.5.0","@testing-library/react":"^13.4.0","jest-environment-jsdom":"^29.7.0","eslint-plugin-storybook":"^0.6.0","@babel/preset-typescript":"^7.23.0","@storybook/addon-actions":"^7.5.0","@testing-library/jest-dom":"^6.1.0","@typescript-eslint/parser":"^6.0.0","eslint-plugin-react-hooks":"^4.6.0","@storybook/testing-library":"^0.2.0","@storybook/addon-essentials":"^7.5.0","@testing-library/user-event":"^14.5.0","@storybook/addon-interactions":"^7.5.0","@typescript-eslint/eslint-plugin":"^6.21.0","eslint-config-standard-with-typescript":"^43.0.1"},"peerDependencies":{"react":">=16.8.0","react-dom":">=16.8.0"},"_npmOperationalInternal":{"tmp":"tmp/use-local-storage_1.0.1_1766403940840_0.9681739636157951","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"publishConfig":{"access":"public"},"name":"@asudbury/use-local-storage","version":"1.0.2","description":"A powerful React hook for LocalStorage management with TypeScript support, serialization, and comprehensive event handling","main":"dist/index.cjs.js","module":"dist/index.esm.js","types":"dist/index.d.ts","scripts":{"build":"tsc","prepare":"npm run build","prepublishOnly":"npm run build","test":"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage","storybook":"storybook dev -p 6006","build-storybook":"storybook build","build-storybook:gh-pages":"storybook build --output-dir storybook-static","preview-storybook":"npx http-server storybook-static -p 8080 -o","storybook:publish":"npm run build-storybook && gh-pages -d storybook-static","lint":"eslint src --ext .ts,.tsx","lint:fix":"eslint src --ext .ts,.tsx --fix","format":"prettier --write src/**/*.{ts,tsx}","format:check":"prettier --check src/**/*.{ts,tsx}","docs:generate":"node scripts/generate-docs.js","docs:markdown":"jsdoc2md --files src/useLocalStorage.ts > docs/api.md","docs:build":"npm run docs:generate","analyze":"node scripts/analyze-bundle.js","release":"npm run test && npm run lint && npm run build && npm run analyze","deploy:storybook":"npm run build-storybook:gh-pages && gh-pages -d storybook-static"},"keywords":["react","hooks","localStorage","typescript","storage","local","state-management","serialization"],"author":{"name":"Your Name"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/asudbury/use-local-storage.git"},"bugs":{"url":"https://github.com/asudbury/use-local-storage/issues"},"homepage":"https://asudbury.github.io/use-local-storage","peerDependencies":{"react":">=16.8.0","react-dom":">=16.8.0"},"devDependencies":{"@babel/core":"^7.23.0","@babel/preset-env":"^7.23.0","@babel/preset-react":"^7.22.0","@babel/preset-typescript":"^7.23.0","@storybook/addon-actions":"^7.5.0","@storybook/addon-essentials":"^7.5.0","@storybook/addon-interactions":"^7.5.0","@storybook/addon-links":"^7.5.0","@storybook/blocks":"^7.5.0","@storybook/react":"^7.5.0","@storybook/react-vite":"^7.5.0","@storybook/testing-library":"^0.2.0","@testing-library/jest-dom":"^6.1.0","@testing-library/react":"^13.4.0","@testing-library/user-event":"^14.5.0","@types/jest":"^29.5.0","@types/react":"^18.2.0","@types/react-dom":"^18.2.0","@typescript-eslint/eslint-plugin":"^6.21.0","@typescript-eslint/parser":"^6.0.0","eslint":"^8.57.1","eslint-config-standard-with-typescript":"^43.0.1","eslint-plugin-import":"^2.32.0","eslint-plugin-n":"^16.6.2","eslint-plugin-promise":"^6.6.0","eslint-plugin-react":"^7.37.5","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-storybook":"^0.6.0","gh-pages":"^6.3.0","husky":"^8.0.0","jest":"^29.7.0","jest-environment-jsdom":"^29.7.0","jsdoc-to-markdown":"^9.1.1","react":"^18.2.0","react-dom":"^18.2.0","storybook":"^7.5.0","typescript":"^5.8.3","vite":"^4.5.0","vite-plugin-dts":"^3.9.1","vitest":"^3.2.4"},"engines":{"node":">=14.0.0"},"browserslist":{"production":[">0.2%","not dead","not op_mini all"],"development":["last 1 chrome version","last 1 firefox version","last 1 safari version"]},"gitHead":"5460c743ced8083c29c89d76ccf87bb11a0eec78","_id":"@asudbury/use-local-storage@1.0.2","_nodeVersion":"24.16.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-uAq2MF0NXlXNmBGG/Uqr2Zuwt1T3i8tvZZopl57zkXES3ERSM1YxmlOfxpjORhJ3GNtd5cQF6V1vBvDzOWb8lg==","shasum":"80b4cdd9120f9ca8e310c8830a4fdd3138080d7b","tarball":"https://registry.npmjs.org/@asudbury/use-local-storage/-/use-local-storage-1.0.2.tgz","fileCount":9,"unpackedSize":48972,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFsfmCGqPDbMLU/FgBl7zFF9anoCGiyzU+tRvoVQ0+76AiAfSJJppjsLEQDhIy/NK5nF1g7m4ToKdiQinB9sBh7WjQ=="}]},"_npmUser":{"name":"asudbury","email":"sudburya@gmail.com"},"directories":{},"maintainers":[{"name":"asudbury","email":"sudburya@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/use-local-storage_1.0.2_1782496395551_0.46633695766457683"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-22T09:44:04.651Z","modified":"2026-06-26T17:53:15.841Z","1.0.0":"2025-12-22T09:44:04.904Z","1.0.1":"2025-12-22T11:45:40.997Z","1.0.2":"2026-06-26T17:53:15.719Z"},"bugs":{"url":"https://github.com/asudbury/use-local-storage/issues"},"author":{"name":"Your Name"},"license":"MIT","homepage":"https://asudbury.github.io/use-local-storage","keywords":["react","hooks","localStorage","typescript","storage","local","state-management","serialization"],"repository":{"type":"git","url":"git+https://github.com/asudbury/use-local-storage.git"},"description":"A powerful React hook for LocalStorage management with TypeScript support, serialization, and comprehensive event handling","maintainers":[{"name":"asudbury","email":"sudburya@gmail.com"}],"readme":"<img src=\"./public/hero-image.png\" >\n\n# useLocalStorage\n\nA powerful, production-ready React hook for LocalStorage management with comprehensive serialization support, type safety, and event handling.\n\n## 📚 DeepWiki Project Knowledge Base\n\n> **Explore the full documentation, architecture, and deep technical notes for this project on DeepWiki:**\n>\n> [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/asudbury/use-local-storage)\n\n## 🎯 Key Features\n\n- **🔄 Automatic Serialization**: JSON serialization/deserialization with error handling\n- **🛡️ Type Safe**: Full TypeScript support with generic types\n- **⚡ Performance Optimized**: Efficient state management and memory leak prevention\n- **🎛️ Event Handling**: Listen to storage changes across tabs/windows\n- **📦 Default Values**: Support for default values and fallbacks\n- **🔍 Validation**: Optional value validation with custom validators\n- **🚫 SSR Safe**: Server-side rendering compatible\n- **🔄 Synchronization**: Automatic sync across multiple hook instances\n- **⏱️ Debounced Updates**: Optional debounced writes for performance\n- **📊 State Management**: Comprehensive loading and error states\n\n## 📦 Installation\n\n```bash\nnpm i @asudbury/use-local-storage\n```\n\n## 🚀 Quick Start\n\n```tsx\nimport useLocalStorage from '@asudbury/use-local-storage';\n\nfunction MyComponent() {\n  const [value, setValue, { loading, error, remove }] = useLocalStorage('my-key', 'default-value');\n\n  return (\n    <div>\n      <input value={value} onChange={(e) => setValue(e.target.value)} disabled={loading} />\n      <button onClick={remove}>Clear</button>\n      {error && <p>Error: {error.message}</p>}\n    </div>\n  );\n}\n```\n\n## 🔧 Advanced Usage\n\n### With TypeScript\n\n```tsx\ninterface User {\n  id: number;\n  name: string;\n  email: string;\n}\n\nfunction UserProfile() {\n  const [user, setUser] = useLocalStorage<User>('user', {\n    id: 0,\n    name: '',\n    email: '',\n  });\n\n  return (\n    <div>\n      <h1>{user.name}</h1>\n      <p>{user.email}</p>\n    </div>\n  );\n}\n```\n\n### With Validation\n\n```tsx\nconst [count, setCount] = useLocalStorage('count', 0, {\n  validator: (value) => {\n    if (typeof value !== 'number') throw new Error('Must be a number');\n    if (value < 0) throw new Error('Must be positive');\n    return value;\n  },\n});\n```\n\n### With Debouncing\n\n```tsx\nconst [text, setText] = useLocalStorage('text', '', {\n  debounceMs: 500, // Wait 500ms before writing to storage\n});\n```\n\n## ⚙️ Configuration Options\n\n```tsx\ninterface UseLocalStorageOptions<T> {\n  serializer?: {\n    parse: (value: string) => T;\n    stringify: (value: T) => string;\n  };\n  validator?: (value: any) => T;\n  debounceMs?: number;\n  syncAcrossInstances?: boolean;\n  onError?: (error: Error) => void;\n}\n```\n\n## 🔄 Event Handling\n\nListen to storage changes across tabs and windows:\n\n```tsx\nconst [theme, setTheme] = useLocalStorage('theme', 'light');\n\n// Automatically syncs when changed in other tabs\nuseEffect(() => {\n  console.log('Theme changed to:', theme);\n}, [theme]);\n```\n\n## 🛡️ Error Handling\n\nThe hook provides comprehensive error handling for:\n\n- JSON parsing errors\n- Storage quota exceeded\n- Invalid values\n- Validation failures\n\n## 📖 API Reference\n\n### Return Value\n\n```tsx\nconst [value, setValue, actions] = useLocalStorage(key, defaultValue, options);\n```\n\n- `value`: Current value from localStorage\n- `setValue`: Function to update the value\n- `actions`: Object with additional actions and states\n  - `loading`: Boolean indicating if operation is in progress\n  - `error`: Error object if operation failed\n  - `remove`: Function to remove the item from storage\n  - `reset`: Function to reset to default value\n\n## 🔧 TypeScript Support\n\nFull TypeScript support with proper type inference and IntelliSense for complete type safety.\n\n## 📄 License\n\nMIT © Adrian Sudbury\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit a [Pull Request](https://github.com/asudbury/use-local-storage/pulls).\n\n- [Open a Pull Request](https://github.com/asudbury/use-local-storage/pulls)\n- [View All Issues](https://github.com/asudbury/use-local-storage/issues)\n- [Create a New Issue](https://github.com/asudbury/use-local-storage/issues/new)\n\n## 📞 Support\n\nIf you have any questions or need help, please [Open an issue](https://github.com/asudbury/use-local-storage/issues) or use the links above.\n\nMade with ❤️ for the React community\n","readmeFilename":"README.md"}