{"_id":"@abundiko/rn-local-storage","_rev":"8-67bffac2643b35cabef58ed864c55696","name":"@abundiko/rn-local-storage","dist-tags":{"latest":"1.2.0"},"versions":{"1.0.0":{"name":"@abundiko/rn-local-storage","version":"1.0.0","keywords":["rn-local-storage","react-native-local-storage","react-native local storage","react native local storage","react native"],"author":{"name":"abundiko"},"license":"MIT","_id":"@abundiko/rn-local-storage@1.0.0","maintainers":[{"name":"abundiko","email":"abundiko111@gmail.com"}],"homepage":"https://github.com/abundiko/rn-local-storage#readme","bugs":{"url":"https://github.com/abundiko/rn-local-storage/issues"},"dist":{"shasum":"a5df014e2953d9318a359eef9e5ae1871b79e55f","tarball":"https://registry.npmjs.org/@abundiko/rn-local-storage/-/rn-local-storage-1.0.0.tgz","fileCount":19,"integrity":"sha512-/Z50c+kbjbrTRMD6vEupr0W3RRazJg9uK1dm89+0xoCLxBX/JoBOmaU+MnxFCE5SOLkd1I6jlJmWJZOfDQimdg==","signatures":[{"sig":"MEYCIQC+jSQ8Ym4FBNsQPXAZQePwsq+rVK1mQMX5j3fqAo5RSAIhAMN2KKHjN7OacrotJN+kCDqChqQ4jsV22SwEl+WDKdY4","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14245},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc","check-exports":"attw --pack .","local-release":"changeset version && changeset publish"},"_npmUser":{"name":"abundiko","email":"abundiko111@gmail.com"},"repository":{"url":"git+https://github.com/abundiko/rn-local-storage.git","type":"git"},"_npmVersion":"10.9.2","description":"Local storage for react native","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.3","@changesets/cli":"^2.28.0","@types/react-native":"^0.72.0","@arethetypeswrong/cli":"^0.17.3"},"peerDependencies":{"zustand":"^4.5.0","react-native-mmkv":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/rn-local-storage_1.0.0_1763548583787_0.24405910826018729","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@abundiko/rn-local-storage","version":"1.0.1","keywords":["rn-local-storage","react-native-local-storage","react-native local storage","react native local storage","react native"],"author":{"name":"abundiko"},"license":"MIT","_id":"@abundiko/rn-local-storage@1.0.1","maintainers":[{"name":"abundiko","email":"abundiko111@gmail.com"}],"homepage":"https://github.com/abundiko/rn-local-storage#readme","bugs":{"url":"https://github.com/abundiko/rn-local-storage/issues"},"dist":{"shasum":"773b7090852eb16a1406dc7ece42676a82e89742","tarball":"https://registry.npmjs.org/@abundiko/rn-local-storage/-/rn-local-storage-1.0.1.tgz","fileCount":19,"integrity":"sha512-tkbS9YAOs2+FJVvwGFhNEJO5uZwZVCLBF4K+ZPTyIX30RVsCMi0sOCbxNCnx2kkaDeRu9wwVNNjvVW76Dt0jxw==","signatures":[{"sig":"MEUCIAtB2j5QeO/qYL9rLJdVpWWEsRqrDElXsz/uRYNk7HPQAiEA0fTQ3rg+FV3uS14+kUe+dcJQQjK8DsrGdm+CxYjQLJ4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14378},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","gitHead":"abf774d4a2587b20d13bee9d68ccccc5d6d730dd","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc","check-exports":"attw --pack .","local-release":"changeset version && changeset publish"},"_npmUser":{"name":"abundiko","email":"abundiko111@gmail.com"},"repository":{"url":"git+https://github.com/abundiko/rn-local-storage.git","type":"git"},"_npmVersion":"10.9.2","description":"Local storage for react native","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.3","@changesets/cli":"^2.28.0","@types/react-native":"^0.72.0","@arethetypeswrong/cli":"^0.17.3"},"peerDependencies":{"zustand":"^4.5.0","react-native-mmkv":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/rn-local-storage_1.0.1_1763549018680_0.04577823725140551","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@abundiko/rn-local-storage","version":"1.0.2","keywords":["rn-local-storage","react-native-local-storage","react-native local storage","react native local storage","react native"],"author":{"name":"abundiko"},"license":"MIT","_id":"@abundiko/rn-local-storage@1.0.2","maintainers":[{"name":"abundiko","email":"abundiko111@gmail.com"}],"homepage":"https://github.com/abundiko/rn-local-storage#readme","bugs":{"url":"https://github.com/abundiko/rn-local-storage/issues"},"dist":{"shasum":"5111912afe1c2dd1383da6a0575663ecb86334da","tarball":"https://registry.npmjs.org/@abundiko/rn-local-storage/-/rn-local-storage-1.0.2.tgz","fileCount":19,"integrity":"sha512-XAYDPbWG3t5vduMZzXhY5piu3aDJcx4AW0Oiq6rybqh3vF/rA0GsWWI6XbS2CbqRWHp4gEfl6RgaGVbvC0KpoQ==","signatures":[{"sig":"MEYCIQCDgwu+Mn3CM3QDaB9yJOXwW5Du466eKB8axUELMqNSMgIhAPX13K+tPC8TBPisKjbGb5BGdvv7gkSUl94eE5eBIjR1","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14379},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","gitHead":"abf774d4a2587b20d13bee9d68ccccc5d6d730dd","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc","check-exports":"attw --pack .","local-release":"changeset version && changeset publish"},"_npmUser":{"name":"abundiko","email":"abundiko111@gmail.com"},"repository":{"url":"git+https://github.com/abundiko/rn-local-storage.git","type":"git"},"_npmVersion":"10.9.2","description":"Local storage for react native","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.3","@changesets/cli":"^2.28.0","@types/react-native":"^0.72.0","@arethetypeswrong/cli":"^0.17.3"},"peerDependencies":{"zustand":">=4.5.0","react-native-mmkv":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/rn-local-storage_1.0.2_1763549652380_0.12225204705061099","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@abundiko/rn-local-storage","version":"1.0.3","keywords":["rn-local-storage","react-native-local-storage","react-native local storage","react native local storage","react native"],"author":{"name":"abundiko"},"license":"MIT","_id":"@abundiko/rn-local-storage@1.0.3","maintainers":[{"name":"abundiko","email":"abundiko111@gmail.com"}],"homepage":"https://github.com/abundiko/rn-local-storage#readme","bugs":{"url":"https://github.com/abundiko/rn-local-storage/issues"},"dist":{"shasum":"a79c64380fe5721e81b467024832a3c54612e746","tarball":"https://registry.npmjs.org/@abundiko/rn-local-storage/-/rn-local-storage-1.0.3.tgz","fileCount":19,"integrity":"sha512-YHIRmgSe6PWK4/QZHEsadtkdS20kANYQmP0oHEUQu8ky+wX+FFlyCW52AZ6HN4kZdy3T3dVuibyMIArEaLdQnA==","signatures":[{"sig":"MEYCIQCp8v0Z64fB3oBBG/WfLkesiuL7XWit9guI5glXdmX2lAIhAKItTwIjNK/50BH5FKCQJd4t1JsEO3Z411KmG9CVZ42C","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14379},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","gitHead":"abf774d4a2587b20d13bee9d68ccccc5d6d730dd","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc","check-exports":"attw --pack .","local-release":"changeset version && changeset publish"},"_npmUser":{"name":"abundiko","email":"abundiko111@gmail.com"},"repository":{"url":"git+https://github.com/abundiko/rn-local-storage.git","type":"git"},"_npmVersion":"10.9.2","description":"Local storage for react native","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.3","@changesets/cli":"^2.28.0","@types/react-native":"^0.72.0","@arethetypeswrong/cli":"^0.17.3"},"peerDependencies":{"zustand":">=4.5.0","react-native-mmkv":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/rn-local-storage_1.0.3_1763718502061_0.22322505301345363","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@abundiko/rn-local-storage","version":"1.0.4","keywords":["rn-local-storage","react-native-local-storage","react-native local storage","react native local storage","react native"],"author":{"name":"abundiko"},"license":"MIT","_id":"@abundiko/rn-local-storage@1.0.4","maintainers":[{"name":"abundiko","email":"abundiko111@gmail.com"}],"homepage":"https://github.com/abundiko/rn-local-storage#readme","bugs":{"url":"https://github.com/abundiko/rn-local-storage/issues"},"dist":{"shasum":"f79953fd3743b394ddf4166ef1f15ef4b57d6043","tarball":"https://registry.npmjs.org/@abundiko/rn-local-storage/-/rn-local-storage-1.0.4.tgz","fileCount":23,"integrity":"sha512-QMNnJ3p8QyJ7eNZ5yG3KfnlgfIECJCXaAuvKhwW+LbR4c4aQfCh0cSsITIqeA6AxfYf9GkIBheI8TPcJILKUrg==","signatures":[{"sig":"MEYCIQDJE+QFGCVII9tw59CWzOCahXMYAr6NFX4/JXJTNGw6RQIhAPlEnpd11wMkeAlWy7KjdKduG2BaRZmkPfV8uJJ+GbPK","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":22932},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","gitHead":"0b582b22439d12c8d2f946f5fd3d330c7994c684","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc","check-exports":"attw --pack .","local-release":"changeset version && changeset publish"},"_npmUser":{"name":"abundiko","email":"abundiko111@gmail.com"},"repository":{"url":"git+https://github.com/abundiko/rn-local-storage.git","type":"git"},"_npmVersion":"10.9.2","description":"Local storage for react native","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.3","@changesets/cli":"^2.28.0","@types/react-native":"^0.72.0","@arethetypeswrong/cli":"^0.17.3"},"peerDependencies":{"zustand":">=4.5.0","react-native-mmkv":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/rn-local-storage_1.0.4_1763993666450_0.5881478088141887","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"@abundiko/rn-local-storage","version":"1.0.5","keywords":["rn-local-storage","react-native-local-storage","react-native local storage","react native local storage","react native"],"author":{"name":"abundiko"},"license":"MIT","_id":"@abundiko/rn-local-storage@1.0.5","maintainers":[{"name":"abundiko","email":"abundiko111@gmail.com"}],"homepage":"https://github.com/abundiko/rn-local-storage#readme","bugs":{"url":"https://github.com/abundiko/rn-local-storage/issues"},"dist":{"shasum":"c87fefe258a619739017a6c0854ded66dda6d886","tarball":"https://registry.npmjs.org/@abundiko/rn-local-storage/-/rn-local-storage-1.0.5.tgz","fileCount":23,"integrity":"sha512-rFdX0LcLaOa6Gwgxvc/HhdYyzrAJsa6hK3eZIEPTi4xYoiaPYwiKVPMrCoIPwiU/h4y5oMxSB/swMAGF2FcYmQ==","signatures":[{"sig":"MEUCIQDwWLPgD+GrEDT0mbAeD7kJFvXXA8PrQax64E3UtVznMgIgLzwQnkcE9COuJHF0Nz+qaQFk6faka/8ZyBMHh/cO9+c=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":22943},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","gitHead":"945b5a4a8cb51af3acd026e414b4b4c8bcc11317","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc","check-exports":"attw --pack .","local-release":"changeset version && changeset publish"},"_npmUser":{"name":"abundiko","email":"abundiko111@gmail.com"},"repository":{"url":"git+https://github.com/abundiko/rn-local-storage.git","type":"git"},"_npmVersion":"11.7.0","description":"Local storage for react native","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.3","@changesets/cli":"^2.28.0","@types/react-native":"^0.72.0","@arethetypeswrong/cli":"^0.17.3"},"peerDependencies":{"zustand":">=4.5.0","react-native-mmkv":"^3.0.0 || ^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/rn-local-storage_1.0.5_1769604093746_0.8333289056813431","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@abundiko/rn-local-storage","version":"1.1.0","keywords":["rn-local-storage","react-native-local-storage","react-native local storage","react native local storage","react native"],"author":{"name":"abundiko"},"license":"MIT","_id":"@abundiko/rn-local-storage@1.1.0","maintainers":[{"name":"abundiko","email":"abundiko111@gmail.com"}],"homepage":"https://github.com/abundiko/rn-local-storage#readme","bugs":{"url":"https://github.com/abundiko/rn-local-storage/issues"},"dist":{"shasum":"d18950de40ec8fa05dfc4d11a1f16a5f2a52ffe6","tarball":"https://registry.npmjs.org/@abundiko/rn-local-storage/-/rn-local-storage-1.1.0.tgz","fileCount":23,"integrity":"sha512-ia+rvX/QXGIijrxTqVRFxLfC0LadupNR7qAwk4XOPIeEwYrUPmO4jMAw/rh4EoJGOj87hmaumON0HZ2+YFpqwg==","signatures":[{"sig":"MEUCIFG0a6Yag5my+BsA+a9sl+Ee0JHzhVYnFPG8+lC+KUIwAiEA4nQU2ghVcE9x6NqUHk1QW3Z7jaXdHYOmYKbCpV/Hs8U=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":22946},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","gitHead":"487883ce32d53b1a70e31aae9c99f24ed4629a63","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc","check-exports":"attw --pack .","local-release":"changeset version && changeset publish"},"_npmUser":{"name":"abundiko","email":"abundiko111@gmail.com"},"repository":{"url":"git+https://github.com/abundiko/rn-local-storage.git","type":"git"},"_npmVersion":"11.7.0","description":"Local storage for react native","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.3","@changesets/cli":"^2.28.0","@types/react-native":"^0.72.0","@arethetypeswrong/cli":"^0.17.3"},"peerDependencies":{"zustand":">=4.5.0","react-native-mmkv":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/rn-local-storage_1.1.0_1769625552523_0.048556779199085076","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@abundiko/rn-local-storage","version":"1.2.0","description":"Local storage for react native","keywords":["rn-local-storage","react-native-local-storage","react-native local storage","react native local storage","react native"],"repository":{"type":"git","url":"git+https://github.com/abundiko/rn-local-storage.git"},"license":"MIT","author":{"name":"abundiko"},"type":"module","main":"dist/index.js","scripts":{"build":"tsc","test":"bun test","check-exports":"attw --pack .","local-release":"changeset version && changeset publish"},"devDependencies":{"@arethetypeswrong/cli":"^0.17.3","@changesets/cli":"^2.28.0","@types/react-native":"^0.72.0","typescript":"^5.7.3"},"peerDependencies":{"react-native-mmkv":"^4.0.0","zustand":">=4.5.0"},"gitHead":"487883ce32d53b1a70e31aae9c99f24ed4629a63","types":"./dist/index.d.ts","_id":"@abundiko/rn-local-storage@1.2.0","bugs":{"url":"https://github.com/abundiko/rn-local-storage/issues"},"homepage":"https://github.com/abundiko/rn-local-storage#readme","_nodeVersion":"24.15.0","_npmVersion":"11.14.1","dist":{"integrity":"sha512-pLDMJZaITRsJRYsMrtHSz/cWIUuMtDrmOWgX/o3HIwmT/kammcQto9zOPSBVba+p8qDZlSwDDfVGnHIBsZaPhA==","shasum":"2313b5e8b20a30c46872acae7b1e2723980f1dad","tarball":"https://registry.npmjs.org/@abundiko/rn-local-storage/-/rn-local-storage-1.2.0.tgz","fileCount":27,"unpackedSize":28992,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDn+MUGa0TFG0jaG1bMOj+YKvolexr52LT2uSw5CA9viQIhALPDpDX8J5WPOg53dykoY8Xc+LxYKy+ePTA3vnKKaHfA"}]},"_npmUser":{"name":"abundiko","email":"abundiko111@gmail.com"},"directories":{},"maintainers":[{"name":"abundiko","email":"abundiko111@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rn-local-storage_1.2.0_1779098735037_0.8815616967563267"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-19T10:36:23.669Z","modified":"2026-05-18T10:05:35.289Z","1.0.0":"2025-11-19T10:36:23.990Z","1.0.1":"2025-11-19T10:43:38.864Z","1.0.2":"2025-11-19T10:54:12.554Z","1.0.3":"2025-11-21T09:48:22.258Z","1.0.4":"2025-11-24T14:14:26.653Z","1.0.5":"2026-01-28T12:41:33.876Z","1.1.0":"2026-01-28T18:39:12.668Z","1.2.0":"2026-05-18T10:05:35.171Z"},"bugs":{"url":"https://github.com/abundiko/rn-local-storage/issues"},"author":{"name":"abundiko"},"license":"MIT","homepage":"https://github.com/abundiko/rn-local-storage#readme","keywords":["rn-local-storage","react-native-local-storage","react-native local storage","react native local storage","react native"],"repository":{"type":"git","url":"git+https://github.com/abundiko/rn-local-storage.git"},"description":"Local storage for react native","maintainers":[{"name":"abundiko","email":"abundiko111@gmail.com"}],"readme":"# @abundiko/rn-local-storage\n\nA lightweight, typed, and reactive local storage hook for React Native, built on top of `react-native-mmkv` and `zustand`.\n\nNOTE: use version `1.0.x` for react-native-mmkv versions `3.x.x`\n\n## Installation\n\n```bash\nnpm install @abundiko/rn-local-storage react-native-mmkv zustand\n# or\nbun add @abundiko/rn-local-storage react-native-mmkv zustand\n```\n\n## NOTE\n\n- if youre using expo, you need to use a development build because `react-native-mmkv` is not supported in the expo go app\n\n## Best Practices\n\n### Create Custom Hooks\n\n**Avoid using `useLocalStorage` directly in your components.**\n\nUsing `useLocalStorage` directly can lead to:\n\n- Scattered magic strings (keys).\n- Inconsistent types across the app.\n- Difficulty in refactoring.\n\nInstead, create domain-specific hooks for each storage key.\n\n#### Example: `useLSTheme`\n\n```tsx\n// hooks/useLSTheme.ts\nimport { useLocalStorage } from \"@abundiko/rn-local-storage\";\n\ntype Theme = \"light\" | \"dark\";\n\nexport const useLSTheme = () => {\n  const { item, setItem } = useLocalStorage<Theme>(\"app-theme\", {\n    defaultValue: \"light\",\n  });\n\n  return {\n    theme: item,\n    setTheme: setItem,\n  };\n};\n```\n\n#### Usage in Component\n\n```tsx\n// App.tsx\nimport { View, Text, Button } from \"react-native\";\nimport { useLSTheme } from \"./hooks/useLSTheme\";\n\nexport default function App() {\n  const { theme, setTheme } = useLSTheme();\n\n  return (\n    <View style={{ backgroundColor: theme === \"light\" ? \"#fff\" : \"#000\" }}>\n      <Text>Current Theme: {theme}</Text>\n      <Button\n        title=\"Toggle Theme\"\n        onPress={() => setTheme(theme === \"light\" ? \"dark\" : \"light\")}\n      />\n    </View>\n  );\n}\n```\n\n## Usage Reference\n\n### Basic Usage\n\n```tsx\nimport { useLocalStorage } from \"@abundiko/rn-local-storage\";\n\nconst { item, setItem, removeItem } = useLocalStorage(\"my-key\", {\n  defaultValue: \"default value\",\n});\n```\n\n### Typed Storage\n\n```tsx\ntype User = {\n  id: string;\n  name: string;\n  age: number;\n};\n\nconst { item: user, setItem: setUser } = useLocalStorage<User>(\"user-profile\", {\n  defaultValue: { id: \"1\", name: \"John\", age: 30 },\n});\n```\n\n### Using Selectors\n\nUse selectors to subscribe to specific parts of the state to optimize performance.\n\n```tsx\nconst { item: userName } = useLocalStorage<User, string>(\"user-profile\", {\n  defaultValue: { id: \"1\", name: \"John\", age: 30 },\n  selector: (user) => user.name,\n});\n```\n\n### Custom Serialization\n\nDisable JSON serialization for simple strings.\n\n```tsx\nconst { item, setItem } = useLocalStorage(\"theme\", {\n  defaultValue: \"light\",\n  jsonSerialize: false, // Store as raw string\n});\n```\n\n### Accessing the Storage Instance\n\nDirect synchronous access to `react-native-mmkv`.\n\n```tsx\nimport { storage } from \"@abundiko/rn-local-storage\";\n\nconst value = storage.getString(\"some-key\");\nstorage.set(\"some-key\", \"some-value\");\n```\n\n### Updating Partial State\n\nShallow merge updates.\n\n```tsx\nconst { updateItem } = useLocalStorage<User>(\"user-profile\", {\n  defaultValue: { id: \"1\", name: \"John\", age: 30 },\n});\n\nupdateItem({ age: 31 });\n```\n\n## API\n\n### `useLocalStorage<T, S>(key, options)`\n\n- **key**: `string` - The unique key for the storage item.\n- **options**: `UseSessionOptions<T, S>`\n  - **defaultValue**: `T` - The value to use if the key does not exist.\n  - **jsonSerialize**: `boolean` (default: `true`) - Enable/disable JSON serialization.\n  - **selector**: `(state: T) => S` - Optional selector function.\n\nReturns:\n\n- **item**: `S` - The current value.\n- **setItem**: `(newValue: T) => void` - Update the value.\n- **removeItem**: `() => void` - Remove the item.\n- **updateItem**: `(partial: Partial<T>) => void` - Shallow update.\n\n### `RNLocalStorage<T>(key, options)` - Non-Hook Implementation\n\nUse this when you need to access local storage outside of React components (e.g., in utility functions, services, or class instances).\n\n- **key**: `string` - The unique key for the storage item.\n- **options**: `UseSessionOptions<T, T>`\n  - **defaultValue**: `T` - The value to use if the key does not exist.\n  - **jsonSerialize**: `boolean` (default: `true`) - Enable/disable JSON serialization.\n\nReturns an object with methods:\n\n- **get**: `() => T` - Get the current value synchronously.\n- **set**: `(newValue: T) => void` - Update the value.\n- **remove**: `() => void` - Remove the item.\n- **update**: `(partial: Partial<T>) => void` - Shallow merge update.\n- **subscribe**: `(callback: (value: T) => void) => () => void` - Subscribe to changes. Returns an unsubscribe function.\n\n## Non-Hook Usage (Outside Components)\n\n### Basic Usage\n\n```ts\nimport { RNLocalStorage } from \"@abundiko/rn-local-storage\";\n\n// Create an instance\nconst themeLSValue = RNLocalStorage<\"light\" | \"dark\">(\"app-theme\", {\n  defaultValue: \"light\",\n});\n\n// Get the current value\nconst currentTheme = themeLSValue.get();\n\n// Set a new value\nthemeLSValue.set(\"dark\");\n\n// Remove the value\nthemeLSValue.remove();\n```\n\n### Typed Storage Outside Components\n\n```ts\ntype User = {\n  id: string;\n  name: string;\n  age: number;\n};\n\nconst userLS = RNLocalStorage<User>(\"user-profile\", {\n  defaultValue: { id: \"1\", name: \"John\", age: 30 },\n});\n\n// Get user\nconst user = userLS.get();\n\n// Update user\nuserLS.set({ id: \"2\", name: \"Jane\", age: 25 });\n\n// Partial update\nuserLS.update({ age: 26 });\n```\n\n### Subscribe to Changes\n\n```ts\nconst themeLSValue = RNLocalStorage<\"light\" | \"dark\">(\"app-theme\", {\n  defaultValue: \"light\",\n});\n\n// Subscribe to changes\nconst unsubscribe = themeLSValue.subscribe((newTheme) => {\n  console.log(\"Theme changed to:\", newTheme);\n  // Update your app's theme engine, etc.\n});\n\n// Later, unsubscribe when no longer needed\nunsubscribe();\n```\n\n### Example: Theme Service\n\n```ts\n// services/ThemeService.ts\nimport { RNLocalStorage } from \"@abundiko/rn-local-storage\";\n\ntype Theme = \"light\" | \"dark\";\n\nclass ThemeService {\n  private themeLS = RNLocalStorage<Theme>(\"app-theme\", {\n    defaultValue: \"light\",\n  });\n\n  getTheme(): Theme {\n    return this.themeLS.get();\n  }\n\n  setTheme(theme: Theme): void {\n    this.themeLS.set(theme);\n  }\n\n  toggleTheme(): void {\n    const current = this.getTheme();\n    this.setTheme(current === \"light\" ? \"dark\" : \"light\");\n  }\n\n  onThemeChange(callback: (theme: Theme) => void): () => void {\n    return this.themeLS.subscribe(callback);\n  }\n}\n\nexport const themeService = new ThemeService();\n```\n","readmeFilename":"README.md"}