{"id":15704155,"url":"https://github.com/yousufkalim/react-easy-router","last_synced_at":"2025-06-24T04:33:55.242Z","repository":{"id":137973789,"uuid":"583428291","full_name":"yousufkalim/react-easy-router","owner":"yousufkalim","description":"The simplest way to add routing to your React app","archived":false,"fork":false,"pushed_at":"2023-04-10T06:28:00.000Z","size":105,"stargazers_count":13,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-03T01:47:48.636Z","etag":null,"topics":["dynamic-routing","nextjs","react-router","reactjs","router","routing"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/yousufkalim.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOGS.md","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":"2022-12-29T18:47:41.000Z","updated_at":"2025-02-21T10:37:48.000Z","dependencies_parsed_at":"2023-07-21T19:57:48.433Z","dependency_job_id":null,"html_url":"https://github.com/yousufkalim/react-easy-router","commit_stats":{"total_commits":39,"total_committers":1,"mean_commits":39.0,"dds":0.0,"last_synced_commit":"26c594521e477d647d87584fd9d98ae768f8e915"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/yousufkalim/react-easy-router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousufkalim%2Freact-easy-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousufkalim%2Freact-easy-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousufkalim%2Freact-easy-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousufkalim%2Freact-easy-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yousufkalim","download_url":"https://codeload.github.com/yousufkalim/react-easy-router/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yousufkalim%2Freact-easy-router/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261604426,"owners_count":23183641,"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":["dynamic-routing","nextjs","react-router","reactjs","router","routing"],"created_at":"2024-10-03T20:10:33.857Z","updated_at":"2025-06-24T04:33:55.200Z","avatar_url":"https://github.com/yousufkalim.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e We are the first generation to feel the sting of climate change, and we are the last generation that can do something about it. Save our planet 🪴\n\n# React Easy Router\n\n- Built on top of react-router-dom\n- The simplest way to add routing to your React app\n- Pass a JS object to the library, and it will handle all the routing\n\n## Prerequisites\n\n- `react-router-dom@6.4.0` or later must be installed in your project\n- Application must be wrapped in a `BrowserRouter` component\n\n## Installation\n\nInstall react-easy-router with npm/yarn\n\n```bash\n  npm install react-easy-router // npm\n  yarn add react-easy-router // yarn\n```\n\n## Examples\n\n**Routes array**\n\n```javascript\nconst routes = [\n  {\n    path: '/',\n    navigate: '/login',\n  },\n  {\n    path: '/login',\n    element: \u003cLogin /\u003e,\n  },\n  {\n    path: '/admins',\n    element: \u003cAdmins /\u003e,\n    children: [{ path: '/admin', element: \u003cAdmin /\u003e }],\n  },\n  {\n    path: '/users',\n    element: \u003cUsers /\u003e,\n    children: [{ path: '/user', element: \u003cUser /\u003e }],\n  },\n  {\n    path: '*',\n    element: \u003cNotFound /\u003e,\n  },\n];\n```\n\n**Dynamic routing**\n\n```javascript\n{\n  path: '/users/:id',\n  element: \u003cUser /\u003e,\n}\n```\n\n**Navigation and redirecting**\n\n```javascript\n{\n  path: '/home',\n  navigate: '/blog',\n}\n```\n\n**Protected routes**\n\n```javascript\n{\n  path: '/admin',\n  element: \u003cAdmin /\u003e,\n  protected: true,\n  roles: [\"admin\", 'manager'], // Optional: Role specific screen\n  failureRedirect: '/admin/login', // Optional: Default is '/'\n}\n```\n\n**Nested routing**\n\n```javascript\n{\n  path: '/users',\n  element: \u003cUsers /\u003e,\n  children: [\n    {\n      path: '/:id',\n      element: \u003cUser /\u003e,\n    },\n  ],\n}\n```\n\n## Usage\n\nHere's an example of basic usage\n\n```javascript\n// src/App.js\nimport Router from 'react-easy-router';\n\nfunction App() {\n  const routes = [...routes];\n\n  return \u003cRouter routes={routes} /\u003e;\n}\n```\n\nProtect with authentication function\n\n```javascript\n// src/App.js\nimport Router from 'react-easy-router';\n\nfunction App() {\n  const routes = [...routes];\n\n  // Function can resolve/reject or return true/false\n  const checkAuth = () =\u003e {\n    const token = localStorage.getItem('token');\n\n    if (token) {\n      return { success: true, role: 'admin' };\n    } else {\n      return false;\n    }\n  };\n\n  return \u003cRouter routes={routes} isAuthenticated={checkAuth} /\u003e;\n}\n```\n\n## Props\n\n**Router**\n\n| Prop            | Type     | Description                                |\n| --------------- | -------- | ------------------------------------------ |\n| routes          | Array    | Array of routes                            |\n| isAuthenticated | Function | Function to check if user is authenticated |\n| showLoader      | Boolean  | Option to disable the loading screen       |\n| loader          | Gif/Svg  | Custom loader element                      |\n\n## Contributing\n\n- Fork it!\n- Create your feature branch: `git checkout -b my-new-feature`\n- Commit your changes: `git commit -am 'Add some feature'`\n- Push to the branch: `git push origin my-new-feature`\n- Submit a pull request :D\n\n## Author\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\n      \u003cimg src=\"https://i.imgur.com/ALrn4wU.jpg\" width=\"100\"\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n      Yousuf Kalim\u003cbr /\u003e\n      \u003ca href=\"mailto:yousufkalim@outlook.com\"\u003eyousufkalim@outlook.com\u003c/a\u003e\u003cbr /\u003e\n      \u003ca href=\"https://yousufkalim.com\"\u003ehttps://yousufkalim.com\u003c/a\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\nAuthored and maintained by Yousuf Kalim.\n\n\u003e GitHub [@yousufkalim](https://github.com/yousufkalim) · LinkedIn [@yousufkalim](https://www.linkedin.com/in/yousufkalim/)\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyousufkalim%2Freact-easy-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyousufkalim%2Freact-easy-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyousufkalim%2Freact-easy-router/lists"}