{"id":13725928,"url":"https://github.com/Patreon/nion","last_synced_at":"2025-05-07T21:30:42.702Z","repository":{"id":33506062,"uuid":"82981739","full_name":"Patreon/nion","owner":"Patreon","description":"🌵  Declarative API Data Management Library built on top of redux 🌵","archived":false,"fork":false,"pushed_at":"2025-04-24T03:31:16.000Z","size":1739,"stargazers_count":126,"open_issues_count":8,"forks_count":9,"subscribers_count":61,"default_branch":"master","last_synced_at":"2025-04-24T04:27:11.417Z","etag":null,"topics":["api","fetch","redux"],"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/Patreon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","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,"zenodo":null}},"created_at":"2017-02-23T23:34:04.000Z","updated_at":"2025-03-26T20:43:28.000Z","dependencies_parsed_at":"2022-08-25T03:01:32.487Z","dependency_job_id":"4817dce9-66da-448e-8891-9e303b6bde4f","html_url":"https://github.com/Patreon/nion","commit_stats":null,"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Patreon%2Fnion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Patreon%2Fnion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Patreon%2Fnion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Patreon%2Fnion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Patreon","download_url":"https://codeload.github.com/Patreon/nion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252957059,"owners_count":21831426,"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":["api","fetch","redux"],"created_at":"2024-08-03T01:02:41.437Z","updated_at":"2025-05-07T21:30:42.398Z","avatar_url":"https://github.com/Patreon.png","language":"JavaScript","funding_links":["https://patreon.com/api/current_user'"],"categories":["JavaScript"],"sub_categories":[],"readme":"# nion\n\nnion is a library that makes it easy to fetch, update, and manage API data in a Redux store as well as bind it to React components. Nion strives to make working with data as **flexible**, **consistent**, and **predictable** as possible. 💖\n\nnion is heavily inspired by [Apollo](http://www.apollodata.com/) and [GraphQL](http://graphql.org/).\n\n## In a Nutshell 🌰\n\nnion is used as a **hook** which is given a declaration of what data is needed by the component that calls it.\n\n```javascript\nimport { useNion } from '@nion/nion'\n\nexport const UserContainer = () =\u003e {\n    const [currentUser, actions, request] = useNion({\n        dataKey: 'currentUser',\n        endpoint: 'https://patreon.com/api/current_user',\n    })\n\n    const loadButton = \u003cButton onClick={() =\u003e actions.get()}\u003eLoad\u003c/Button\u003e\n\n    return (\n        \u003cCard\u003e\n            {request.isLoading ? \u003cLoadingSpinner /\u003e : loadButton}\n            {currentUser \u0026\u0026 \u003cUserCard user={currentUser} /\u003e}\n        \u003c/Card\u003e\n    )\n}\n```\n\nWe simply pass in a [`declaration`](docs/glossary.md#declaration) object that tells nion **what** to fetch, and nion automatically handles fetching the data and returning it along with the corresponding request status.\n\nnion can also be used as a **decorator function** which declares what data will be managed by the decorated component and passes in props for managing that data. This is a deprecated usage; we don't recommend writing new code that uses the decorator form.\n\nSee also:\n\n-   [Examples](docs/examples.md), a list of common scenarios when using nion\n-   [How nion works](docs/howitworks.md), a deep dive\n\n## Up and Running 🏃🏾‍♀️\n\n### Installation\n\nnion requires `redux-thunk` in order to handle its async actions, so you should install that along with the `nion` package.\n\n```\nnpm install nion redux-thunk --save\n```\n\nSince nion can be used as a decorator function, you might want to make sure you've got babel configured to handle decorator transpilation:\n\n```\nnpm install babel-plugin-transform-decorators-legacy --save-dev\n```\n\n### Configuration\n\nFinally, nion has to be wired up to the redux store and optionally configured. Here's a very simple setup:\n\n```javascript\nimport { applyMiddleware, createStore, combineReducers } from 'redux'\nimport thunkMiddleware from 'redux-thunk'\n\nimport { configureNion } from 'nion'\n\nexport default function configureStore() {\n    const configurationOptions = {}\n    const { reducer: nionReducer } = configureNion(configurationOptions)\n\n    const reducers = combineReducers({\n        nion: nionReducer,\n    })\n\n    let store = createStore(reducers, applyMiddleware(thunkMiddleware))\n\n    return store\n}\n```\n\n[Read more about configuring nion in the docs.](docs/configuration.md)\n\n## Read More 📚\n\n-   [Declarations](docs/declarations.md)\n-   [Configuring Nion](docs/configuration.md)\n-   [API Modules](docs/api-modules.md)\n-   [Extensions](docs/extensions.md)\n-   [Glossary](docs/glossary.md)\n-   [How it Works](docs/howitworks.md)\n-   Lifecycle (documentation coming soon 😳)\n\n## Licensing 🍴\n\n[MIT](license.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPatreon%2Fnion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPatreon%2Fnion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPatreon%2Fnion/lists"}