{"id":15131704,"url":"https://github.com/charlesstover/use-react-router","last_synced_at":"2025-09-28T23:32:09.020Z","repository":{"id":57388304,"uuid":"154884397","full_name":"CharlesStover/use-react-router","owner":"CharlesStover","description":"React Hook for pub-sub behavior using React Router.","archived":true,"fork":false,"pushed_at":"2022-09-19T21:47:32.000Z","size":30,"stargazers_count":567,"open_issues_count":1,"forks_count":30,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-12-20T23:22:09.380Z","etag":null,"topics":["npm","npmjs","react","react-hooks","react-router","reactjs","travis","travis-ci","travisci","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/use-react-router","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/CharlesStover.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":"2018-10-26T19:27:46.000Z","updated_at":"2024-11-30T05:23:04.000Z","dependencies_parsed_at":"2022-09-02T06:00:49.436Z","dependency_job_id":null,"html_url":"https://github.com/CharlesStover/use-react-router","commit_stats":null,"previous_names":["quisido/use-react-router","charlesstover/use-react-router"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CharlesStover%2Fuse-react-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CharlesStover%2Fuse-react-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CharlesStover%2Fuse-react-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CharlesStover%2Fuse-react-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CharlesStover","download_url":"https://codeload.github.com/CharlesStover/use-react-router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234575214,"owners_count":18854924,"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":["npm","npmjs","react","react-hooks","react-router","reactjs","travis","travis-ci","travisci","typescript"],"created_at":"2024-09-26T04:00:52.493Z","updated_at":"2025-09-28T23:32:08.640Z","avatar_url":"https://github.com/CharlesStover.png","language":"TypeScript","readme":"# useReactRouter\n\n[![version](https://img.shields.io/npm/v/use-react-router.svg)](https://www.npmjs.com/package/use-react-router)\n[![downloads](https://img.shields.io/npm/dt/use-react-router.svg)](https://www.npmjs.com/package/use-react-router)\n[![minzipped size](https://img.shields.io/bundlephobia/minzip/use-react-router.svg)](https://www.npmjs.com/package/use-react-router)\n\n`useReactRouter` is a React Hook that provides pub-sub behavior for `react-router`.\nUnlike the `withRouter` Higher-Order Component, `useReactRouter` will re-render your component when the location changes!\n\n`useReactRouter()` returns an object that contains the `history`, `location`, and `match` properties that would be passed as props by the HOC.\n\nA tutorial covering the design and development of this package can be found on Medium: [How to Convert withRouter to a React Hook](https://medium.com/@Charles_Stover/how-to-convert-withrouter-to-a-react-hook-19bb02a29ed6).\n\n## Why Pub-Sub?\n\nPub-sub behavior is a common request (that's commonly rejected) for the `react-router` package.\n\nFor users who adamently prefer pub-sub behavior over `react-router`'s suggested alternatives, this package offers a solution.\n\nA non-pub-sub React Hook is anticipated to eventually be included in the `react-router` package itself.\n\n## Install\n\n**You must be using `react-router` and `react-router-dom` v5.0.0 or greater.**\n\n* `npm install use-react-router` or\n* `yarn add use-react-router`\n\n## Use\n\nImport `useReactRouter` and use it as a React Hook.\n\n```JavaScript\nimport useReactRouter from 'use-react-router';\n\nconst MyPath = () =\u003e {\n  const { history, location, match } = useReactRouter();\n  return (\n    \u003cdiv\u003e\n      My location is {location.pathname}!\n    \u003c/div\u003e\n  );\n};\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharlesstover%2Fuse-react-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharlesstover%2Fuse-react-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharlesstover%2Fuse-react-router/lists"}