{"id":15601169,"url":"https://github.com/hacknlove/usestorage","last_synced_at":"2025-04-26T21:32:21.837Z","repository":{"id":57114850,"uuid":"199811551","full_name":"hacknlove/usestorage","owner":"hacknlove","description":"react state hook for using browser extension storage","archived":false,"fork":false,"pushed_at":"2019-08-09T13:36:12.000Z","size":11,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-27T02:03:30.140Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hacknlove.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-31T08:16:12.000Z","updated_at":"2024-04-25T02:37:13.000Z","dependencies_parsed_at":"2022-08-22T06:30:59.515Z","dependency_job_id":null,"html_url":"https://github.com/hacknlove/usestorage","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2Fusestorage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2Fusestorage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2Fusestorage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2Fusestorage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hacknlove","download_url":"https://codeload.github.com/hacknlove/usestorage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224048108,"owners_count":17246957,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T02:19:09.709Z","updated_at":"2024-11-11T04:29:17.015Z","avatar_url":"https://github.com/hacknlove.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# usestorage\nreact state hook for using browser extension storage\n\n## Install\n```\nnpm i @hacknlove/usestorage\n```\n\n## API\n\n### `useStorage(key, first = null, area = 'sync')`\n* `key` **string**: the key to be retrieved\n* `first` **any** the initial value to be returned before get the actual one.\n* `area` **'sync' or 'local'** the storage to use.\n\nreturns `[value, set]` with the value in the storage at `key` and a function to update the key in the storage\n\n### `preStore(keys, area = 'sync'`)\n* `key` **array** of the keys to be cached\n* `area` the storage to use.\n\nspeed up `useStorage` caching the actual values for the first use.\n\n## Example\n```javascript\nimport React from 'react'\nimport ReactDOM from 'react-dom'\nimport useStorage, { preStore } from '@hacknlove/usestorage'\n\npreStore(['world']) // optional optimization\n\nfunction Example () {\n  const [world, setWorld] = useStorage('world')\n\n\n  return (\n    \u003ch1\u003eHello {world}\u003c/h1\u003e\n    \u003cbutton onClick={() =\u003e setWorld('earth')}\u003eWorld's name\u003c/button\u003e\n  )\n}\n\nReactDOM.render(\n  \u003cExample/\u003e,\n  document.querySelector('#root')\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacknlove%2Fusestorage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhacknlove%2Fusestorage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacknlove%2Fusestorage/lists"}