{"id":24738652,"url":"https://github.com/zweifisch/revelte","last_synced_at":"2026-04-10T02:51:04.448Z","repository":{"id":262922629,"uuid":"888789822","full_name":"zweifisch/revelte","owner":"zweifisch","description":"$state() and $effect() for react","archived":false,"fork":false,"pushed_at":"2024-12-02T00:50:16.000Z","size":84,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-29T02:43:15.952Z","etag":null,"topics":["react","swc-plugin"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/zweifisch.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-15T02:25:40.000Z","updated_at":"2024-12-02T00:50:19.000Z","dependencies_parsed_at":"2024-11-15T03:25:15.713Z","dependency_job_id":"5965c1a0-4df2-4a27-bfcd-c76cc2d0681e","html_url":"https://github.com/zweifisch/revelte","commit_stats":null,"previous_names":["zweifisch/revelte"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zweifisch/revelte","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Frevelte","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Frevelte/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Frevelte/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Frevelte/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zweifisch","download_url":"https://codeload.github.com/zweifisch/revelte/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Frevelte/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281044370,"owners_count":26434606,"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-10-25T02:00:06.499Z","response_time":81,"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":["react","swc-plugin"],"created_at":"2025-01-27T22:55:16.535Z","updated_at":"2025-10-26T01:08:39.989Z","avatar_url":"https://github.com/zweifisch.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# revelte\n\n`$state()` and `$effect()` for react\n\n```jsx\nimport type {} from 'revelte'\n\nfunction App() {\n  let count = $state(0)\n  $effect(() =\u003e {\n    console.log(`count: ${count}`)\n  })\n  return \u003cdiv onClick={() =\u003e count += 1}\u003e{count}\u003c/div\u003e\n}\n```\n## Why\n\nYou get immutable state for free:\n\n```jsx\nstate.foo.bar += 1\n```\n\ninstead of \n\n```jsx\nsetState({...state, foo: {...state.foo, bar: state.foo.bar + 1}})\n```\n\n## Setup\n\n```sh\nnpm create vite@latest my-react-app -- --template react-swc-ts\ncd my-react-app\nnpm i -D revelte\n```\n\nin `vite.config.ts` add `revelte` as a plugin:\n\n```js\nexport default defineConfig({\n  plugins: [react({plugins: [['revelte', {}]]})],\n})\n```\n\n```sh\nnpm run dev\n```\n\n## When will state be updated\n\n- reassigning $state variables, like `count = newVal`\n- mutating object $state variables, like `foo.bar = newVal`\n- mutating arrays, including `push`, `pop`, `unshift`, `shift`, `splice`, `fill`, `reverse`, `sort` and `copyWithin`\n- always operate directly on the original $state object, otherwise state won't change\n\nInstead of:\n```js\nlet state = $state({count: 1})\nconst {count} = state\ncount += 1\n```\n\nUse:\n```js\nstate.count += 1\n```\n\n## How does it work\n\nCode are rewritten to use `useState` and `useEffect`, so there is almost no runtime overhead.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzweifisch%2Frevelte","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzweifisch%2Frevelte","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzweifisch%2Frevelte/lists"}