{"id":15687069,"url":"https://github.com/blakeembrey/react-route","last_synced_at":"2025-08-10T10:12:13.157Z","repository":{"id":46940084,"uuid":"159007792","full_name":"blakeembrey/react-route","owner":"blakeembrey","description":"React Location with Path-to-RegExp","archived":false,"fork":false,"pushed_at":"2025-06-24T05:29:39.000Z","size":1259,"stargazers_count":8,"open_issues_count":10,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-08T14:11:53.404Z","etag":null,"topics":["path-to-regexp","react","react-location","react-router","router"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blakeembrey.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"blakeembrey"}},"created_at":"2018-11-25T07:20:05.000Z","updated_at":"2025-07-26T18:31:51.000Z","dependencies_parsed_at":"2024-10-23T20:36:19.303Z","dependency_job_id":"0b41e87a-8f09-46c3-aff0-7c61c46ddb97","html_url":"https://github.com/blakeembrey/react-route","commit_stats":{"total_commits":65,"total_committers":2,"mean_commits":32.5,"dds":"0.18461538461538463","last_synced_commit":"71f766444a0c198bd4706173cbbafd0283a4bb53"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/blakeembrey/react-route","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeembrey%2Freact-route","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeembrey%2Freact-route/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeembrey%2Freact-route/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeembrey%2Freact-route/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blakeembrey","download_url":"https://codeload.github.com/blakeembrey/react-route/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeembrey%2Freact-route/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269548500,"owners_count":24436113,"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-08-09T02:00:10.424Z","response_time":111,"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":["path-to-regexp","react","react-location","react-router","router"],"created_at":"2024-10-03T17:42:55.368Z","updated_at":"2025-08-10T10:12:13.127Z","avatar_url":"https://github.com/blakeembrey.png","language":"TypeScript","funding_links":["https://github.com/sponsors/blakeembrey"],"categories":[],"sub_categories":[],"readme":"# React Route\n\n[![NPM version][npm-image]][npm-url]\n[![NPM downloads][downloads-image]][downloads-url]\n[![Build status][travis-image]][travis-url]\n[![Test coverage][coveralls-image]][coveralls-url]\n[![Bundle size][bundlephobia-image]][bundlephobia-url]\n\n\u003e [Path-to-RegExp](https://github.com/pillarjs/path-to-regexp) with [React Location](https://github.com/blakeembrey/react-location).\n\n## Installation\n\n```\nnpm install @blakeembrey/react-route --save\n```\n\n## Usage\n\nUse with [React Location](https://github.com/blakeembrey/react-location).\n\n```js\nimport {\n  Route,\n  Switch,\n  useRoutePath,\n  useMatch,\n  usePathMatch,\n  usePathCompile,\n} from \"@blakeembrey/react-route\";\n```\n\n### `Route`\n\nConditionally renders `component` when the path matches the active URL.\n\n```js\nconst App = () =\u003e {\n  return (\n    \u003cRoute\n      path=\"/page/:id\"\n      component={(params) =\u003e \u003cdiv\u003e{JSON.stringify(params)}\u003c/div\u003e}\n    /\u003e\n  );\n}; // `/123` =\u003e `\u003cdiv\u003e[\"123\"]\u003c/div\u003e`\n```\n\nSupports `path-to-regexp` properties:\n\n- **sensitive** When `true`, the regexp will be case sensitive. (default: `false`)\n- **strict** When `true`, optional trailing delimiters will not match. (default: `false`)\n- **end** When `true`, the regexp will match to the end of the string. (default: `true`)\n- **start** When `true`, the regexp will match to the beginning of the string. (default: `true`)\n\n### `Switch`\n\nComponent for matching and rendering the first `\u003cRoute /\u003e` of children.\n\n```js\nconst App = () =\u003e {\n  return (\n    \u003cSwitch fallback={...}\u003e\n      \u003cRoute path=\"/me\" component={() =\u003e \u003cspan\u003eBlake\u003c/span\u003e} /\u003e\n      \u003cRoute path=\"/:id\" component={({ id }) =\u003e \u003cdiv\u003e{id}\u003c/div\u003e} /\u003e\n      \u003cRoute end={false} component={() =\u003e \u003cdiv\u003e404 Not Found\u003c/div\u003e} /\u003e\n    \u003c/Switch\u003e\n  );\n}; // `/me` =\u003e `\u003cspan\u003eBlake\u003c/span\u003e`\n```\n\n### `useRoutePath`\n\nReturns the current pathname based on the router (e.g. route prefixes are removed).\n\n```js\nuseRoutePath(); //=\u003e \"/foo\"\n```\n\n### `useMatch`\n\nCreate a `path-to-regexp` match function and run it on the current path.\n\n```js\nconst App = () =\u003e {\n  const result = useMatch(\"/test\");\n\n  return \u003cdiv\u003e{JSON.stringify(result)}\u003c/div\u003e;\n}; //=\u003e `\u003cdiv\u003e{\"params\":[],\"index\":0,\"path\":\"/test\"}\u003c/div\u003e`\n```\n\n### `usePathMatch`\n\nCreate a `path-to-regexp` match function.\n\n```js\nconst App = () =\u003e {\n  const match = usePathMatch(\"/test\");\n\n  return \u003cdiv\u003e{JSON.stringify(match(\"/\"))}\u003c/div\u003e;\n}; //=\u003e `\u003cdiv\u003efalse\u003c/div\u003e`\n```\n\n### `usePathCompile`\n\nCreates a `path-to-regexp` path function.\n\n```js\nconst App = () =\u003e {\n  const path = usePathCompile(\"/:id\")({ id: 123 });\n\n  return \u003cLink to={path}\u003eUser {id}\u003c/Link\u003e;\n};\n```\n\n## TypeScript\n\nThis project uses [TypeScript](https://github.com/Microsoft/TypeScript) and publishes definitions on NPM.\n\n## License\n\nApache 2.0\n\n[npm-image]: https://img.shields.io/npm/v/@blakeembrey/react-route.svg?style=flat\n[npm-url]: https://npmjs.org/package/@blakeembrey/react-route\n[downloads-image]: https://img.shields.io/npm/dm/@blakeembrey/react-route.svg?style=flat\n[downloads-url]: https://npmjs.org/package/@blakeembrey/react-route\n[travis-image]: https://img.shields.io/travis/blakeembrey/react-route.svg?style=flat\n[travis-url]: https://travis-ci.org/blakeembrey/react-route\n[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/react-route.svg?style=flat\n[coveralls-url]: https://coveralls.io/r/blakeembrey/react-route?branch=master\n[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/@blakeembrey/react-route.svg\n[bundlephobia-url]: https://bundlephobia.com/result?p=@blakeembrey/react-route\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakeembrey%2Freact-route","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblakeembrey%2Freact-route","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakeembrey%2Freact-route/lists"}