{"id":13445954,"url":"https://github.com/tj/react-enroute","last_synced_at":"2025-05-15T07:06:39.301Z","repository":{"id":48780218,"uuid":"61212242","full_name":"tj/react-enroute","owner":"tj","description":"React router with a small footprint for modern browsers","archived":false,"fork":false,"pushed_at":"2023-03-15T05:18:33.000Z","size":2418,"stargazers_count":1487,"open_issues_count":5,"forks_count":22,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-14T10:42:43.271Z","etag":null,"topics":[],"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/tj.png","metadata":{"files":{"readme":"Readme.md","changelog":"Changelog.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":"2016-06-15T13:57:44.000Z","updated_at":"2025-03-23T05:42:09.000Z","dependencies_parsed_at":"2024-06-18T15:17:49.786Z","dependency_job_id":"4d9293b6-a409-4d0e-af47-4ad15bb5b357","html_url":"https://github.com/tj/react-enroute","commit_stats":{"total_commits":141,"total_committers":4,"mean_commits":35.25,"dds":"0.12056737588652477","last_synced_commit":"e5a3056a7ff97a2bb1c4030d94a143cba3973432"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj%2Freact-enroute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj%2Freact-enroute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj%2Freact-enroute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj%2Freact-enroute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tj","download_url":"https://codeload.github.com/tj/react-enroute/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254227584,"owners_count":22035665,"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":[],"created_at":"2024-07-31T05:00:42.490Z","updated_at":"2025-05-15T07:06:34.286Z","avatar_url":"https://github.com/tj.png","language":"JavaScript","funding_links":[],"categories":["Uncategorized","JavaScript","React"],"sub_categories":["Uncategorized","React Components"],"readme":"# react-enroute\n\nSimple React router with a small footprint for modern browsers. The lib is not\nreplacement for react-router, just a smaller simpler alternative.\n\nSee [path-to-regexp](https://github.com/pillarjs/path-to-regexp#usage)\nfor matching pattern rules and options. Check\n[encode and decode](https://github.com/pillarjs/path-to-regexp#match)\nif you need it.\n\nRouter size [limited](https://github.com/ai/size-limit) to **~2 KB**\n(all deps, minified and gzipped).\n\n## Installation\n\n```console\nyarn add react-enroute\n```\n\nor\n\n```console\nnpm install react-enroute\n```\n\n## Usage\n\nNo nesting:\n\n```js\n\u003cRouter location='/pets/42'\u003e\n  \u003cIndex/\u003e\n  \u003cUsers path='/users'/\u003e\n  \u003cUser path='/users/:id'/\u003e\n  \u003cPets path='/pets'/\u003e\n  \u003cPet path='/pets/:id'/\u003e\n  \u003cNotFound path='(.*)'/\u003e\n\u003c/Router\u003e\n```\n\nNesting and options:\n\n```js\nconst RouterOptions = {decode: decodeURIComponent}\n\n\u003cRouter location='/users/caf%C3%A9' options={RouterOptions}\u003e\n  \u003cMain/\u003e                     // '/'\n\n  \u003cUsers path='/users'\u003e\n    \u003cAllUsers/\u003e               // '/users'\n    \u003cUser path=':id'/\u003e        // '/users/:id'\n  \u003c/Users\u003e\n    \n  \u003cPets path='/pets'\u003e\n    \u003cPet path=':id'/\u003e\n    \u003cMyPets path='/my-pets'/\u003e // absolute path\n  \u003c/Pets\u003e\n\n  \u003cNotFound path='(.*)'/\u003e\n\u003c/Router\u003e\n```\n\nFollowing route with the same full path overrides previous. Matching goes\nfrom top to bottom, so more general rules coming first take precedence. You\nshould put more concrete rules above catch-all.\n\nRight order:\n\n```js\n\u003cRouter\u003e\n  \u003cMike path='mike'/\u003e\n  \u003cOtherPerson path=':name'/\u003e\n  \u003cNotFound path='(.*)'/\u003e\n\u003c/Router\u003e\n```\n\n**Not found** page (404) should be the last.\n\nPaths may not start with `/`, the name-based syntax is ok:\n\n```js\n\u003cRouter location='pets'\u003e\n  \u003cIndex/\u003e               // use '' or '/' for index location\n  \u003cUsers path='users'/\u003e\n  \u003cPets path='pets'/\u003e\n\u003c/Router\u003e\n```\n\n## Utils\n\n### genLocation (alias: loc)\n\nGenerate location based on a path and params.\n\n```js\ngenLocation('/users/:id', {id: '42'}) // =\u003e '/users/42'\nloc('/pets/:id', {id: '123'}) // =\u003e '/pets/123'\n```\n\n### isPath\n\nCheck if location matches path.\n\n```js\nisPath('/users/:id', '/users/42') // =\u003e true\n```\n\n### findPath\n\nSearch path by location.\n\n```js\nfindPath(['/users', '/users/:id'], '/users/42')\n/* =\u003e {\n  path: '/users/:id',\n  params: {id: '42'},\n} */\n```\n\n### findPathValue\n\nSearch over object whose keys are paths.\n\n```js\nfindPathValue({\n '/users': UserListToolbar,\n '/users/:id': UserToolbar,\n}, '/users/42')\n/* =\u003e {\n path: '/users/:id',\n value: UserToolbar,\n params: {id: '42'},\n} */\n```\n\n## Badges\n\n![](https://img.shields.io/badge/license-MIT-blue.svg)\n![](https://img.shields.io/badge/status-stable-green.svg)\n[![](http://apex.sh/images/badge.svg)](https://apex.sh/ping/)\n\n---\n\n\u003e [tjholowaychuk.com](http://tjholowaychuk.com) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e GitHub [@tj](https://github.com/tj) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e Twitter [@tjholowaychuk](https://twitter.com/tjholowaychuk)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftj%2Freact-enroute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftj%2Freact-enroute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftj%2Freact-enroute/lists"}