{"id":18582977,"url":"https://github.com/astahmer/jotai-yjs","last_synced_at":"2025-09-14T06:06:24.944Z","repository":{"id":57281654,"uuid":"390538610","full_name":"astahmer/jotai-yjs","owner":"astahmer","description":"jotai-yjs makes yjs state even easier","archived":false,"fork":false,"pushed_at":"2021-07-29T12:17:28.000Z","size":90,"stargazers_count":39,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-07T19:55:33.125Z","etag":null,"topics":["crdt","jotai","react","typescript","valtio","yjs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/astahmer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-28T23:34:01.000Z","updated_at":"2025-02-12T04:48:23.000Z","dependencies_parsed_at":"2022-09-19T22:06:15.645Z","dependency_job_id":null,"html_url":"https://github.com/astahmer/jotai-yjs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/astahmer/jotai-yjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astahmer%2Fjotai-yjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astahmer%2Fjotai-yjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astahmer%2Fjotai-yjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astahmer%2Fjotai-yjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/astahmer","download_url":"https://codeload.github.com/astahmer/jotai-yjs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astahmer%2Fjotai-yjs/sbom","scorecard":{"id":213238,"data":{"date":"2025-08-11","repo":{"name":"github.com/astahmer/jotai-yjs","commit":"b03252ba1253a2675759fca7c31782941b3795a9"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"Code-Review","score":0,"reason":"Found 0/11 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":"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":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"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":-1,"reason":"no dependencies found","details":null,"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":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"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":"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":"Vulnerabilities","score":0,"reason":"36 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-cph5-m8f7-6c5x","Warn: Project is vulnerable to: GHSA-wf5p-g6vw-rhxx","Warn: Project is vulnerable to: GHSA-jr5f-v2jv-69x6","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-phwq-j96m-2c2q","Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6","Warn: Project is vulnerable to: GHSA-67mh-4wv8-2f99","Warn: Project is vulnerable to: GHSA-74fj-2j2h-c42q","Warn: Project is vulnerable to: GHSA-pw2r-vq6v-hr8c","Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc","Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc","Warn: Project is vulnerable to: GHSA-mv48-hcvh-8jj8","Warn: Project is vulnerable to: GHSA-353f-5xf4-qw67","Warn: Project is vulnerable to: GHSA-64vr-g452-qvp3","Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx","Warn: Project is vulnerable to: GHSA-vg6x-rcgg-rjx6","Warn: Project is vulnerable to: GHSA-x574-m823-4x7w","Warn: Project is vulnerable to: GHSA-4r4m-qw57-chr8","Warn: Project is vulnerable to: GHSA-xcj6-pq6g-qj4x","Warn: Project is vulnerable to: GHSA-356w-63v5-8wf4","Warn: Project is vulnerable to: GHSA-859w-5945-r5v3","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"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-17T01:08:27.803Z","repository_id":57281654,"created_at":"2025-08-17T01:08:27.803Z","updated_at":"2025-08-17T01:08:27.803Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275067238,"owners_count":25399655,"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","status":"online","status_checked_at":"2025-09-14T02:00:10.474Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["crdt","jotai","react","typescript","valtio","yjs"],"created_at":"2024-11-07T00:18:02.572Z","updated_at":"2025-09-14T06:06:24.912Z","avatar_url":"https://github.com/astahmer.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jotai-yjs 💊🚀\n\njotai-yjs makes yjs state [even easier](https://github.com/dai-shi/valtio-yjs)\n\n\nhttps://user-images.githubusercontent.com/47224540/127463982-3332da94-4bf6-46c5-9a2e-f67d54ac7cb3.mp4\n\n\n\n## What is this\n\n[valtio](https://github.com/pmndrs/valtio) is\na proxy state library for ReactJS and VanillaJS.\n[yjs](https://github.com/yjs/yjs) is\nan implmentation of CRDT algorithm. [jotai](https://github.com/pmndrs/jotai) is a primitive and flexible state management for React.\n\njotai-yjs is a three-way binding to bridge them. Typescript ready btw.\n\n## Project status\n\nIt started as an experiment, and the experiment is finished.\nNow, it's in alpha.\n\n## Install\n\n```bash\nyarn add react jotai-yjs jotai valtio valtio-yjs yjs\n```\n\n## How to use it\n\n```ts\nimport * as Y from \"yjs\";\nimport { useYArray, useYMap } from \"jotai-yjs\";\n\n// create a new Y doc\nconst ydoc = new Y.Doc();\n\n// useYArray \u0026 useYMap returns the proxy source so that you can mutate it directly thanks to valtio-yjs\nconst settings = useYMap\u003cSettings\u003e(yDoc, \"settings\");\n\n// here we're creating a proxy array (thanks to valtio-yjs) available globally (thanks to jotai) through its name, \"games\", attached to the yDoc we created earlier\nconst gamesSource = useYArray\u003cGame\u003e(yDoc, \"games\");\n\n// and here you can get the snapshot to read from it, as per the valtio docs https://github.com/pmndrs/valtio#react-via-usesnapshot\nconst games = useSnapshot(gamesSource);\n\n// you can do anything you could do with valtio here with those\n```\n\n# Adding a provider\n\n\u003e Currently, I only tried it with a WebsocketProvider but as long as the provider as an `awareness` property it should work the same.\n\n```ts\n// [optional] create a provider\nconst provider = new WebsocketProvider(wsUrl, yDoc.guid, yDoc, { connect: false });\n\n// here we're creating an init function that should be called only once in the hook below\nconst addProviderToDoc = () =\u003e {\n    console.log(\"connect to a ws provider with room\", yDoc.guid);\n\n    provider.connect();\n    // do what/ever you want with that provider here\n\n    return () =\u003e {\n        console.log(\"disconnect\", yDoc.guid);\n        provider.destroy();\n    };\n};\n\n// very basic hook which purpose is to connect the provider to the server\nexport const useProviderInit = () =\u003e {\n    useEffect(() =\u003e {\n        const unmount = addProviderToDoc();\n        return () =\u003e unmount();\n    }, []);\n\n    return yDoc;\n};\n```\n\n# Presence\n\nUsing hooks, you get access to what I call your `presence`, which is the current user local awareness state in YJS terms.\nIt is used like a `useState`, as simple as :\n\n```ts\nconst [presence, setPresence] = usePresence();\n```\n\nBut that `usePresence` hook doesn't come straight from `jotai-yjs`, it comes from you !\n\nYou can create it using the `makePresence` function and passing your custom arguments.\n\n```ts\nimport { makePresence } from \"jotai-yjs\";\n\n// provider could be the WebsocketProvider that we created earlier\n// initialPresence is the object to use as the initial local awareness state, aka presence\n// onUpdate is an optional function that is called whenever the presence is updated and takes the current presence as argument,\n\n// here, persistPlayer could be an action like persisting the presence to localStorage\nexport const { useYAwarenessInit, useYAwareness, presenceProxy, usePresence, usePresenceSnap } = makePresence({\n    provider,\n    initialPresence: player,\n    onUpdate: persistPlayer,\n});\n```\n\nInspired by [`zustand`](https://github.com/pmndrs/zustand) hook store.\n\nQuite a lot coming from that `makePresence` return ! Let's see what comes from it:\n\n-   `useYAwarenessInit`: hook to init the provider, basically it syncs an atom with each updates from the [`awareness`](https://docs.yjs.dev/getting-started/adding-awareness) service\n-   `useYAwareness`: returns the resulting `awareness` state set by`useYAwarenessInit`\n-   `presenceProxy`: the actual proxy source created by `valtio`\n-   `usePresence`: we talked about that one already [here](#presence)\n-   `usePresenceSnap`: just a shortcut, it's basically `const usePresenceSnap = () =\u003e useSnapshot(presenceProxy);`\n\nAnd since all of these hooks were created by **YOU**, you don't need to pass any arguments ! You did that already when you used `makePresence` so everything will be deduced from here.\n\n## Demos\n\n\u003e you can check the [demo app in the repository](./demo/src/pages/Demo.tsx) made with [this template](https://github.com/astahmer/vite-chakra)\n\nUsing `usePresence` and\n`WebsocketProvider` in [y-websocket](https://github.com/yjs/y-websocket),\nwe can create multi-client React apps pretty easily.\n\n-   https://codesandbox.io/s/github/astahmer/jotai-yjs/tree/main/demo?file=/src/pages/Demo.tsx\n-   (...open a PR to add your demos)\n\n# Notes\n\nHuge thanks to [Daishi Kato](https://twitter.com/dai_shi) for everything he does.\nI copy/pasted valtio-yjs README and changed a few things to make this one so this might look familiar.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastahmer%2Fjotai-yjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fastahmer%2Fjotai-yjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastahmer%2Fjotai-yjs/lists"}