{"id":15601164,"url":"https://github.com/hacknlove/onget","last_synced_at":"2026-02-25T17:08:11.049Z","repository":{"id":35136858,"uuid":"208782119","full_name":"hacknlove/onGet","owner":"hacknlove","description":"The KISS, write-less do more, elegant, plugin-extensible way to handle state with diverse origins.","archived":false,"fork":false,"pushed_at":"2023-03-03T08:15:40.000Z","size":6228,"stargazers_count":10,"open_issues_count":40,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-22T12:06:14.501Z","etag":null,"topics":["javascript","onget","react","reactive-programming","state"],"latest_commit_sha":null,"homepage":"","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-16T11:23:29.000Z","updated_at":"2024-04-25T02:18:47.000Z","dependencies_parsed_at":"2024-11-11T04:29:45.886Z","dependency_job_id":"37129fa5-4c75-4087-ba48-571ee5a25d78","html_url":"https://github.com/hacknlove/onGet","commit_stats":{"total_commits":223,"total_committers":2,"mean_commits":111.5,"dds":"0.12107623318385652","last_synced_commit":"df111640a137171512c3e8b4c934814a270395d4"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2FonGet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2FonGet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2FonGet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2FonGet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hacknlove","download_url":"https://codeload.github.com/hacknlove/onGet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243581059,"owners_count":20314167,"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":["javascript","onget","react","reactive-programming","state"],"created_at":"2024-10-03T02:19:03.478Z","updated_at":"2025-10-26T20:14:36.823Z","avatar_url":"https://github.com/hacknlove.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# onGet\n\nThis is the KISS, write-less do more, elegant, scalable, and plugin-extensible way to deal with reactive state in modern applications.\n\n## Why\n\nI have tried a bunch of solutions, and It did not feel right. They have a lot of unnecessary complexity, they lacked of liberty and there were too much trouble everywher.\n\nI wrote the first version of onGet in 3 months in 2019, but then I started working in a couple of projects for other people, and I thought that it was better to use something standard and broadly used, so I went back to redux. After a while I found SWR, and I though, cool man, I was not completly wrong, some guys has done something similar, and I started using SWR in my projects too. But now I remembered how much easier and fun was onGet, so I am here again, making it Even if I am the only one using it, It's worth it, because it makes a great difference on how you work, and I want to spend my time making great apps with great UX, instead of trying to hack some weirdiness to make it run.\n\nNow I am making it play nicer with NextJS, because it's the framework I am using, and I must say I am very satisfied on how it's going so far.\n\nonGet + nextjs it's a wonderfull combination.\n\n## Documentation\n[documentation](https://hacknlove.github.io/onGet/)\n\n\n## Characteristics\n\n1. It allows you to design a sort of client-side CRUDy API that organize your application state as url-accessible resources.\n2. Then your application can access, change, and subscribe to this resources through urls.\n3. It follows a \"Batteries included\" Philosophy, to help you deal with undoable histories, deep states, remote APIs, localStorage and fast.\n4. It is extensible through plugins, so you can add a new kind of resources to fit your needs.\n5. You can add transformations and validations to the values you set to the resources.\n6. You use expressjs-like paths to add more functionality to your API\n6. If you do server-side rendering or prerendering, you can use serialize the state and share it with the client.\n7. You can also serialize and deserialize client-side, to store your state in any client-side storage you want, like localstorage or indexedDB\n\n## install \n```\nnpm i onget@2\n```\n## Basic Usage. Examples\n\n### Set and get the value of a resource\n```js\nimport { get, set } from 'onget'\n\nget('fast://foo') // undefined\n\nset('fast://foo', 'bar')\n\nget('fast://foo') // 'bar'\n\n```\n\n### Subscribe to a resource\n```js\nimport { onGet, set } from 'onget'\n\nconst unsubscribe = onGet('fast://hello', value =\u003e { // handler\n  console.log(value)\n}, {\n  first: 'word' // Optionally set a first value only if the response has no value yet\n})\n\nset('fast://hello', 'Earth') // The handler will be executed\n\nunsubscribe() // You can unsubscribe\n\nset('fast://hello', 'Mars') // The handler will not be executed\n```\n\n### React hook\n```js\nimport React from 'react'\nimport { useOnGet } from 'onget'\n\nexport function MyComponent () {\n  const myValue = useOnGet('fast://myResource')\n\n  return (\n    \u003cp\u003e{myValue}\u003c/p\u003e\n  )\n}\n```\n\n### Modify the behavior of `set`\n\n```js\nimport { beforeSet, set } from 'onget'\n\nbeforeSet('fast://day', context =\u003e {\n  if (![\n    'monday',\n    'tuesday',\n    'wednesday',\n    'thursday',\n    'friday',\n    'saturday',\n    'sunday'\n  ].includes(value)) {\n    context.preventSet = true // prevent the set\n  }\n})\nset('fast://day', 'monday')\n// get('fast://day') -\u003e 'monday'\nset('fast://day', 'fooday')\n// get('fast://day') -\u003e 'monday'\n\n\nbeforeSet('fast://count/:item', context =\u003e {\n  context.value = parseInt(context.value) // modify the value to be set\n})\nset('fast://count/happyness', '42')\n// get('fast://count/happyness') -\u003e 42\nset('fast://count/life', 12.3) // 12\n// get('fast://count/life') -\u003e 12\n```\n\n\n### Execute some function after the set\n```js\nimport { afterSet, set } from 'onget'\n\nafterSet('/api/name', context =\u003e {\n  fetch('/api/name', {\n    method: 'POST',\n    body: JSON.stringify({\n      name: context.value\n    }),\n    headers: {\n      'Content-Type': 'application/json'\n    }\n  })\n})\n\nset('/api/name', 'johndoe') // a HTTP POST request will be done\n```\n\n## Examples\n\n**Forked from https://github.com/reduxjs/redux/tree/master/examples**\n\n* counter [source](/examples/counter) [sandbox](https://codesandbox.io/s/github/hacknlove/onGet/tree/master/examples/counter)\n* Todos [source](/master/examples/todos) [sandbox](https://codesandbox.io/s/github/hacknlove/onGet/tree/master/examples/todos)\n* Todos-with-undo [source](/examples/todos-with-undo) [sandbox](https://codesandbox.io/s/github/hacknlove/onGet/tree/master/examples/todos-with-undo)\n* TodoMVC [source](/master/examples/todomvc) [sandbox](https://codesandbox.io/s/github/hacknlove/onGet/tree/master/examples/todomvc)\n* Shopping-cart [source](/examples/shopping-cart)\n* Tree-view [source](/examples/tree-view) [sandbox](https://codesandbox.io/s/github/hacknlove/onGet/tree/master/examples/tree-view)\n* Async [source](/examples/async) [sandbox](https://codesandbox.io/s/github/hacknlove/onGet/tree/master/examples/async)\n* Universal [source](/examples/universal)\n\n**Realworld Code challenges**\n\n* WheatherMaps [source](/codingChallenges/WheatherMaps) [sandbox](https://codesandbox.io/s/github/hacknlove/onGet/tree/master/codingChallenges/WheatherMaps)\n* walmartlabs [source](/codingChallenges/walmartlabs) [sandbox](https://codesandbox.io/s/github/hacknlove/onGet/tree/master/codingChallenges/walmartlabs)\n* FlowKey [source](/codingChallenges/piano) [sandbox](https://codesandbox.io/s/piano-wkfoe)\n\n**Other framework tutorial redone the onGet way**\n* grommet [source](https://github.com/hacknlove/grommet-vending-onget) [sandbox](https://codesandbox.io/s/github/hacknlove/grommet-vending-onget/tree/onget)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacknlove%2Fonget","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhacknlove%2Fonget","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacknlove%2Fonget/lists"}