{"id":24112663,"url":"https://github.com/fabiulous/react-redux-permissions","last_synced_at":"2025-12-11T18:34:50.063Z","repository":{"id":47549155,"uuid":"110533004","full_name":"fabiulous/react-redux-permissions","owner":"fabiulous","description":"A permissions library for react and redux applications.","archived":false,"fork":false,"pushed_at":"2018-02-08T11:16:42.000Z","size":40,"stargazers_count":43,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-08T14:31:49.551Z","etag":null,"topics":["permissions","react","react-native","redux"],"latest_commit_sha":null,"homepage":null,"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/fabiulous.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":"2017-11-13T10:19:05.000Z","updated_at":"2022-11-21T05:59:08.000Z","dependencies_parsed_at":"2022-09-26T17:00:46.962Z","dependency_job_id":null,"html_url":"https://github.com/fabiulous/react-redux-permissions","commit_stats":null,"previous_names":["fabiulous/react-redux-permissions","shizpi/react-redux-permissions"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fabiulous/react-redux-permissions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiulous%2Freact-redux-permissions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiulous%2Freact-redux-permissions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiulous%2Freact-redux-permissions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiulous%2Freact-redux-permissions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fabiulous","download_url":"https://codeload.github.com/fabiulous/react-redux-permissions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiulous%2Freact-redux-permissions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275695771,"owners_count":25511349,"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-17T02:00:09.119Z","response_time":84,"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":["permissions","react","react-native","redux"],"created_at":"2025-01-11T03:59:36.812Z","updated_at":"2025-09-18T01:32:01.661Z","avatar_url":"https://github.com/fabiulous.png","language":"JavaScript","funding_links":[],"categories":["📦 Legacy \u0026 Inactive Projects"],"sub_categories":[],"readme":"**react-redux-permissions** is a simple library to handle your react application permissions using redux.\n\n## Installation\n\n```\nnpm i react-redux-permissions --save\n```\n\nor \n\n```\nyarn add react-redux-permissions\n```\n\n## Features\n\n* Disable views and components\n* Provide a fallback component for users without permission\n* Designed for react-redux\n* High Order Component option\n\n## Requirements\n\n* node \u003e= 4.0.0\n\n## Usage\n\n### Reducer\n\nImport the reducer and pass it to your store:\n\n``` javascript\nimport { createStore, combineReducers } from 'redux';\n\nimport { reducer as permissions } from \"react-redux-permissions\"\n\nexport function configureStore(initialState = {}) {\n  return createStore(\n    combineReducers({\n      permissions\n    }),\n    initialState\n  );\n}\n```  \n### Actions\nAdd roles to the current user:\n\n```javascript\nimport { add } from \"react-redux-permissions\"\n\ndispatch(add(\"manager\"))\ndispatch(add(\"canSeeMessages\")) // Pretty much anything\n```\nRemove roles from the current user:\n\n```javascript\nimport { remove } from \"react-redux-permissions\"\n\ndispatch(remove(\"canSeeMessages\"))\n```\n\nRemove all roles. Useful once you logout.\n```javascript\nimport { clear } from \"react-redux-permissions\"\n\ndispatch(clear())\n```\n\n### Component\n\nYou can limit access to your views using the default Permissions component.\n\n#### allowed\nWith the `allowed` prop, only users with one of the permissions will be able to see child components.\n```javascript\nimport Permissions from \"react-redux-permissions\"\n\n...\n\n\u003cPermissions\n  allowed={[\"paying\"]}\n\u003e\n  \u003cRoute path=\"/dashboard\" component={DashboardView} /\u003e\n\u003c/Permissions\u003e\n```\n#### except\nWith the `except` prop, every user except the ones with the passed permission will be able to see child components.\n```javascript\nimport Permissions from \"react-redux-permissions\"\n\n...\n\n\u003cPermissions\n  except={[\"paying\"]}\n\u003e\n  \u003cRoute path=\"/dashboard\" component={DashboardView} /\u003e\n\u003c/Permissions\u003e\n```\n\n#### fallbackElement\nYou can send a `fallbackElement` to show an alternative view for users without permission\n```javascript\nimport Permissions from \"react-redux-permissions\"\n\n...\n\n\u003cPermissions\n  except={[\"paying\"]}\n  fallbackElement={\u003cDashboardDisabled /\u003e}\n\u003e\n  \u003cRoute path=\"/dashboard\" component={DashboardView} /\u003e\n\u003c/Permissions\u003e\n```\n\n### HOC\nYou can also use a High Order Component to disable views and components:\n\nSend allowed roles as the first argument and disallowed as the second argument.\nYou can also provide a fallback component as second argument of the second function.\n```javascript\nimport { HOC as Permissions } from \"react-redux-permissions\"\n\nconst DashboardView = Permissions(\n  [\"admin\", \"paying\"],\n  [\"trial\"]\n)(Dashboard, \u003cModuleDisabled view=\"Dashboard\" /\u003e)\n\n...\n\n\u003cRoute path=\"/dashboard\" component={DashboardView} /\u003e\n```\n\nAvoid using it like:\n```javascript\nimport { HOC as Permissions } from \"react-redux-permissions\"\n\nconst DashboardView = Permissions([\"admin\", \"paying\"], [\"trial\"])\n\n...\nrender() {\n  return (\n    ...\n    \u003cRoute path=\"/dashboard\" component={DashboardView(Dashboard, \u003cModuleDisabled view=\"Dashboard\" /\u003e)} /\u003e\n    ...\n  )\n}\n```\nThis approach inside render will make react mount the component again and cause undesired effects.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/shizpi/react-redux-permissions. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n\n## License\n\nThe module is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiulous%2Freact-redux-permissions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabiulous%2Freact-redux-permissions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiulous%2Freact-redux-permissions/lists"}