{"id":27774302,"url":"https://github.com/saeedsheikhi/authenticated-react-router","last_synced_at":"2025-10-30T07:45:46.113Z","repository":{"id":57187163,"uuid":"172123534","full_name":"SaeedSheikhi/authenticated-react-router","owner":"SaeedSheikhi","description":"extended components for handling authenticated routes in react-router","archived":false,"fork":false,"pushed_at":"2021-01-17T10:34:16.000Z","size":49,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-30T02:18:02.692Z","etag":null,"topics":["authentication","react","react-router","router"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SaeedSheikhi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-22T19:30:25.000Z","updated_at":"2022-04-27T16:46:50.000Z","dependencies_parsed_at":"2022-08-28T10:51:24.019Z","dependency_job_id":null,"html_url":"https://github.com/SaeedSheikhi/authenticated-react-router","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaeedSheikhi%2Fauthenticated-react-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaeedSheikhi%2Fauthenticated-react-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaeedSheikhi%2Fauthenticated-react-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaeedSheikhi%2Fauthenticated-react-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SaeedSheikhi","download_url":"https://codeload.github.com/SaeedSheikhi/authenticated-react-router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251626898,"owners_count":21617744,"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":["authentication","react","react-router","router"],"created_at":"2025-04-30T02:18:07.659Z","updated_at":"2025-10-30T07:45:46.040Z","avatar_url":"https://github.com/SaeedSheikhi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# authenticated-react-router\n\nextended components for handling authenticated routes in react-router, manage your private and public routes easily.\njust replace Main Route component with AuthenticatedRouter or UnauthenticatedRouter components, see below for installation and use cases.\n\n## Installation\n\n### Yarn\n\n```sh\n$ yarn add authenticated-react-router\n```\n\n## Usage\n\n### AuthenticatedRoute\n\nonly allow authenticated (logged in) users to pass the route, particulary use for private routes such as profile section that need user to be logged in.\n\n#### Props\n\n| Prop            | Description                                                                    |\n| --------------- | ------------------------------------------------------------------------------ |\n| isAuthenticated | a boolean flag that show user is logged in or not                              |\n| redirect        | if user was not logged in redirect user to this location, often is /login page |\n| path            | Same as React-Router                                                           |\n| component       | Same as React-Router                                                           |\n\n```javascript\nimport React, { Component } from \"react\";\nimport { Route } from \"react-router-dom\";\nimport { AuthenticatedRoute } from \"authenticated-react-router\";\n//\nimport Profile from \"./components/Profile\";\nimport Login from \"./components/Login\";\nimport Register from \"./components/Register\";\n\nclass App extends Component {\n  render() {\n    return (\n      \u003csection\u003e\n        \u003cAuthenticatedRoute\n          path=\"/profile\"\n          redirect=\"/login\"\n          isAuthenticated={this.props.isAuthenticated}\n          component={Profile}\n        /\u003e\n        \u003cRoute exact path=\"/search\" component={Search} /\u003e\n      \u003c/section\u003e\n    );\n  }\n}\n\nexport default App;\n```\n\n### UnauthenticatedRoute\n\nforce logged in users redirect to pass this route, particularly use for login or register routes that logged in user doesn't need to see.\n\n#### Props\n\n| Prop            | Description                                                                                                                                                                                     |\n| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| isAuthenticated | a boolean flag that show user is logged in or not                                                                                                                                               |\n| redirect        | if user was logged in redirect user to this location, modules will automatically redirect user where he is came but for general purporse you must pass an generic url for example /profile page |\n| path            | Same as React-Router                                                                                                                                                                            |\n| component       | Same as React-Router                                                                                                                                                                            |\n\n```javascript\nimport React, { Component } from \"react\";\nimport { Route } from \"react-router-dom\";\nimport { UnauthenticatedRoute } from \"authenticated-react-router\";\n//\nimport Profile from \"./components/Profile\";\nimport Login from \"./components/Login\";\nimport Register from \"./components/Register\";\n\nclass App extends Component {\n  render() {\n    return (\n      \u003csection\u003e\n        \u003cUnauthenticatedRoute\n          path=\"/login\"\n          isAuthenticated={this.props.isAuthenticated}\n          redirect=\"/profile\"\n          component={Login}\n        /\u003e\n        \u003cUnauthenticatedRoute\n          path=\"/register\"\n          isAuthenticated={this.props.isAuthenticated}\n          redirect=\"/profile\"\n          component={Register}\n        /\u003e\n        \u003cRoute exact path=\"/search\" component={Search} /\u003e\n      \u003c/section\u003e\n    );\n  }\n}\n\nexport default App;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaeedsheikhi%2Fauthenticated-react-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaeedsheikhi%2Fauthenticated-react-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaeedsheikhi%2Fauthenticated-react-router/lists"}