{"id":20227131,"url":"https://github.com/imrdjai/usesync","last_synced_at":"2026-02-07T13:02:24.899Z","repository":{"id":40247170,"uuid":"332065762","full_name":"iMrDJAi/useSync","owner":"iMrDJAi","description":"A subscription based state management solution for React!","archived":false,"fork":false,"pushed_at":"2022-06-01T08:32:05.000Z","size":38,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-27T17:56:17.638Z","etag":null,"topics":["hook","hooks","react","react-hook","react-hooks","react-state","state","state-management","usesync"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iMrDJAi.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":"2021-01-22T21:23:54.000Z","updated_at":"2022-05-09T22:04:06.000Z","dependencies_parsed_at":"2022-09-19T02:31:14.921Z","dependency_job_id":null,"html_url":"https://github.com/iMrDJAi/useSync","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/iMrDJAi/useSync","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iMrDJAi%2FuseSync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iMrDJAi%2FuseSync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iMrDJAi%2FuseSync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iMrDJAi%2FuseSync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iMrDJAi","download_url":"https://codeload.github.com/iMrDJAi/useSync/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iMrDJAi%2FuseSync/sbom","scorecard":{"id":476814,"data":{"date":"2025-08-11","repo":{"name":"github.com/iMrDJAi/useSync","commit":"4d3ac7c21b93bff72b73fa5d0e5ebd477260fc2a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.8,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/6 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/npm-publish.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/iMrDJAi/useSync/npm-publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/iMrDJAi/useSync/npm-publish.yml/main?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/npm-publish.yml:20","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 9 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":3,"reason":"7 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-67mh-4wv8-2f99","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-3mv9-4h5g-vhg3"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T15:31:10.366Z","repository_id":40247170,"created_at":"2025-08-19T15:31:10.366Z","updated_at":"2025-08-19T15:31:10.366Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29194423,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T12:38:28.597Z","status":"ssl_error","status_checked_at":"2026-02-07T12:38:23.888Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["hook","hooks","react","react-hook","react-hooks","react-state","state","state-management","usesync"],"created_at":"2024-11-14T07:22:59.808Z","updated_at":"2026-02-07T13:02:24.881Z","avatar_url":"https://github.com/iMrDJAi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"***\n# **useSync**\n[![npm](https://img.shields.io/npm/v/usesync?color=red)](https://www.npmjs.com/package/usesync)\n\nA subscription based state management solution for React!\n***\n\n## Table of Contents\n-   [Installation](#installation)\n-   [Usage](#usage)\n-   [Notes](#notes)\n-   [License](#license)\n\n## Installation:\n\nInstall the package from **npm**:\n```bash\n$ npm install usesync --save\n```\n\nThen simply require it:\n```js\nconst { useSync, sync, storage } = require(\"usesync\") // CJS\n```\nor\n```js\nimport useSync, { sync, storage } from \"usesync\" // ESM\n```\n\n## Usage:\n### useSync(id: string, initialValue?: any): any\n\nThis is the hook that you will use across your React components, it allows them to subscribe to a specific sync with the ID you give:\n```js\nconst Component = () =\u003e {\n    useSync('hello')\n    return (\n        \u003cdiv\u003e\n            Hello World!\n        \u003c/div\u003e\n    )\n}\n```\n\nSubscribing to muiltiple syncs is possible, just call the hook multiple times with different IDs:\n```js\nconst Component = () =\u003e {\n    useSync('id num 1')\n    useSync('id num 2')\n    return (\n        \u003cdiv\u003e\n            Hello World!\n        \u003c/div\u003e\n    )\n}\n```\n\nUpdating sync IDs at runtime is allowed:\n```js\nconst GreetUser = (id) =\u003e {\n    const user = getUser(id)\n    useSync(`Users ${id}`)\n    return (\n        \u003cdiv\u003e\n            Hello {user.firstName}!\n        \u003c/div\u003e\n    )\n}\n```\n\nTo synchronize state in multiple components simply call the hook inside all of them and give the same ID:\n```js\nconst ComponentA = () =\u003e {\n    const name = useSync('hello', 'World')\n    return (\n        \u003cdiv\u003e\n            Hello {name}! (A)\n        \u003c/div\u003e\n    )\n}\nconst ComponentB = () =\u003e {\n    const name = useSync('hello', 'World')\n    return (\n        \u003cdiv\u003e\n            Hello {name}! (B)\n        \u003c/div\u003e\n    )\n}\n```\n\n### sync(id: string, newValue?: any): void\n\nThe hook alone does nothing, to dispatch a sync you need to call this function, this will cause all the subscribed components to re-render. Here is an example:\n```js\nimport React from 'react'\nimport ReactDOM from 'react-dom'\nimport useSync, { sync } from \"usesync\"\n\n\nconst ComponentA = () =\u003e {\n    useSync('Components')\n    return (\n        \u003cdiv\u003e\n            Random Number (A): {Math.random()}\n        \u003c/div\u003e\n    )\n}\nconst ComponentB = () =\u003e {\n    useSync('Components')\n    useSync('ComponentB')\n    return (\n        \u003cdiv\u003e\n            Random Number (B): {Math.random()}\n        \u003c/div\u003e\n    )\n}\nconst ComponentC = () =\u003e {\n    useSync('Components')\n    return (\n        \u003cdiv\u003e\n            Random Number (C): {Math.random()}\n        \u003c/div\u003e\n    )\n}\nconst App = () =\u003e {\n    const handleClick = () =\u003e {\n        sync('Components')\n    }\n    const handleClick2 = () =\u003e {\n        sync('ComponentB')\n    }\n    return (\n        \u003cdiv\u003e\n            \u003cComponentA /\u003e\n            \u003cComponentB /\u003e\n            \u003cComponentC /\u003e\n            \u003cComponentC /\u003e\n            \u003cbutton onClick={handleClick}\u003ere-render all\u003c/button\u003e\n            \u003cbutton onClick={handleClick2}\u003ere-render component b\u003c/button\u003e\n        \u003c/div\u003e\n    )\n}\n\nReactDOM.render(\u003cApp /\u003e, document.getElementById('app'))\n```\nTry it on [CodePen](https://codepen.io/imrdjai/pen/zYKQzqw)!\n\n**New:** You may pass a sync value to this function, and access it from the subscribed components:\n```js\nimport React from 'react'\nimport ReactDOM from 'react-dom'\nimport useSync, { sync } from \"usesync\"\n\n\nconst initialValue = Math.random()\n\nconst ComponentA = () =\u003e {\n    const randomNumber = useSync('Components', initialValue)\n    return (\n        \u003cdiv\u003e\n            Random Number (A): {randomNumber}\n        \u003c/div\u003e\n    )\n}\nconst ComponentB = () =\u003e {\n    const randomNumber = useSync('Components', initialValue)\n    return (\n        \u003cdiv\u003e\n            Random Number (B): {randomNumber}\n        \u003c/div\u003e\n    )\n}\nconst ComponentC = () =\u003e {\n    const randomNumber = useSync('Components', initialValue)\n    return (\n        \u003cdiv\u003e\n            Random Number (C): {randomNumber}\n        \u003c/div\u003e\n    )\n}\nconst App = () =\u003e {\n    const handleClick = () =\u003e {\n        sync('Components', Math.random())\n    }\n    return (\n        \u003cdiv\u003e\n            \u003cComponentA /\u003e\n            \u003cComponentB /\u003e\n            \u003cComponentC /\u003e\n            \u003cComponentC /\u003e\n            \u003cbutton onClick={handleClick}\u003ere-render all\u003c/button\u003e\n        \u003c/div\u003e\n    )\n}\n\nReactDOM.render(\u003cApp /\u003e, document.getElementById('app'))\n```\nTry it on [CodePen](https://codepen.io/imrdjai/pen/WNMwvJx)!\n\n### storage: Object\n\nThis is an optional object that is globaly available across your app, it can be used to store states for your componenets. Here is an example:\n```js\nimport React from 'react'\nimport ReactDOM from 'react-dom'\nimport useSync, { sync, storage } from \"usesync\"\n\n\nstorage.randomNumber = Math.random()\n\nconst ComponentA = () =\u003e {\n    useSync('Components')\n    return (\n        \u003cdiv\u003e\n            Random Number (A): {storage.randomNumber}\n        \u003c/div\u003e\n    )\n}\nconst ComponentB = () =\u003e {\n    useSync('Components')\n    useSync('ComponentB')\n    return (\n        \u003cdiv\u003e\n            Random Number (B): {storage.randomNumber}\n        \u003c/div\u003e\n    )\n}\nconst ComponentC = () =\u003e {\n    useSync('Components')\n    return (\n        \u003cdiv\u003e\n            Random Number (C): {storage.randomNumber}\n        \u003c/div\u003e\n    )\n}\nconst App = () =\u003e {\n    const handleClick = () =\u003e {\n        storage.randomNumber = Math.random()\n        sync('Components')\n    }\n    const handleClick2 = () =\u003e {\n        storage.randomNumber = Math.random()\n        sync('ComponentB')\n    }\n    return (\n        \u003cdiv\u003e\n            \u003cComponentA /\u003e\n            \u003cComponentB /\u003e\n            \u003cComponentC /\u003e\n            \u003cComponentC /\u003e\n            \u003cbutton onClick={handleClick}\u003ere-render all\u003c/button\u003e\n            \u003cbutton onClick={handleClick2}\u003ere-render component b\u003c/button\u003e\n        \u003c/div\u003e\n    )\n}\n\nReactDOM.render(\u003cApp /\u003e, document.getElementById('app'))\n```\nTry it on [CodePen](https://codepen.io/imrdjai/pen/XWjwqxO)!\n\n## Notes\nGive this cool project a star ⭐! I will appreciate it ❤\n\n[![GitHub Repo stars](https://img.shields.io/github/stars/iMrDJAi/useSync?style=social)](https://github.com/iMrDJAi/useSync)\n\n## License\n[MIT](https://github.com/iMrDJAi/useSync/blob/master/LICENSE) © [iMrDJAi](https://github.com/iMrDJAi)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimrdjai%2Fusesync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimrdjai%2Fusesync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimrdjai%2Fusesync/lists"}