{"id":14977662,"url":"https://github.com/emilte/named-routes","last_synced_at":"2026-02-05T00:34:46.766Z","repository":{"id":59860067,"uuid":"539657176","full_name":"emilte/named-routes","owner":"emilte","description":"npmjs package for improved named routes.","archived":false,"fork":false,"pushed_at":"2022-09-23T15:42:05.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-08T15:53:31.009Z","etag":null,"topics":["npm","npm-module","npm-package","npmjs","react","react-router","react-router-dom","reactjs","router","routing"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@emilte/named-routes","language":"TypeScript","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/emilte.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":"2022-09-21T19:40:12.000Z","updated_at":"2022-09-27T21:09:42.000Z","dependencies_parsed_at":"2023-01-18T20:46:04.223Z","dependency_job_id":null,"html_url":"https://github.com/emilte/named-routes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/emilte/named-routes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilte%2Fnamed-routes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilte%2Fnamed-routes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilte%2Fnamed-routes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilte%2Fnamed-routes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emilte","download_url":"https://codeload.github.com/emilte/named-routes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilte%2Fnamed-routes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29103407,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-04T22:44:52.815Z","status":"ssl_error","status_checked_at":"2026-02-04T22:44:16.428Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["npm","npm-module","npm-package","npmjs","react","react-router","react-router-dom","reactjs","router","routing"],"created_at":"2024-09-24T13:56:05.802Z","updated_at":"2026-02-05T00:34:46.751Z","avatar_url":"https://github.com/emilte.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# named-routes\n\nInspired by named-urls ([npmjs](https://www.npmjs.com/package/named-urls), [github](https://github.com/kennedykori/named-urls/))\n\nAs I am unsure of how forking works, this package is a direct copy of the package above.\nI have extended the functionality with a few additions:\n1. Removed toString() method.\n3. Added `base`: Raw path given to include(), not affected by nesting.\n4. Added `star`: Raw base as route representation to catch all patterns. `base` suffixed with `/*`.\n5. Added `self`: Full path to `base`.\n\n\u003cbr\u003e\n\u003chr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n## Example setup:\n```ts\n// \"src/routes.ts\"\nimport { include } from '@emilte/named-routes';\n\nexport const ROUTES = {\n   foo: include('/foo/', {\n        bar: 'bar/',\n        scope: include('scope/:param', { // \u003c- Note optional trailing slash.\n            baz: 'baz', // \u003c- Note optional trailing slash.\n            qux: 'qux/',\n            nos: '/nos/' // \u003c- Note absolute path.\n     })\n   })\n}\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eFinal result\u003c/summary\u003e\n\n```ts\nROUTES = {\n    foo: {\n        base: '/foo/',\n        star: '/foo/*',\n        self: '/foo/',\n        bar: '/foo/bar/',\n        scope: {\n            base: 'scope/:param',\n            star: 'scope/:param/*',\n            self: '/foo/scope/:param',\n            baz: '/foo/scope/:param/baz',\n            qux: '/foo/scope/:param/qux/',\n            nos: '/nos/'\n        }\n    }\n}\n```\n\u003c/details\u003e\n\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n## Usage:\n\nExample 1 (simple):\n```ts\nROUTES.foo.base === '/foo/'\nROUTES.foo.self === '/foo/'\nROUTES.foo.star === '/foo/*'\n\nROUTES.foo.scope.base === 'scope/:param'\nROUTES.foo.scope.star === 'scope/:param/*'\nROUTES.foo.scope.self === '/foo/scope/:param'\n\nROUTES.foo.scope.baz === '/foo/scope/:param/baz'\n\nROUTES.foo.scope.qux === '/foo/scope/:param/qux/'\n\nROUTES.foo.scope.nos === '/nos/'\n\n// Use `reverse` to inject params.\nreverse(ROUTES.foo.scope.baz, {param:'hello-world'}) === '/foo/scope/hello-world/baz'\n```\n\nExample 2 (router):\n```tsx\n// \"src/AppRoutes.tsx\"\nimport { Route, Routes } from 'react-router-dom';\nimport { BazPage, QuxPage } from 'Pages'; // Some example components.\nimport { ROUTES } from 'routes'; // From example setup.\nimport { FooRoutes } from 'src'; // Some other nested routing.\n\nexport function AppRoutes() {\n    return (\n        \u003cRoutes\u003e\n            \u003cRoute path={ROUTES.foo.scope.baz} element={BazPage} /\u003e\n            \u003cRoute path={ROUTES.foo.scope.qux} element={QuxPage} /\u003e\n            \u003cRoute path={ROUTES.foo.star} element={FooRoutes} /\u003e {/* Catch everything else */}\n        \u003c/Routes\u003e\n    )\n}\n```\n\nExample 3 (link):\n```tsx\n// \"src/Pages/BazPage.tsx\"\nimport { reverse } from '@emilte/named-routes';\nimport { ROUTES } from 'routes'; // From example setup.\n\nexport function BazPage() {\n    const quxOneUrl = reverse(ROUTES.foo.scope.qux, {param: 1})\n    return \u003ca href={quxOneUrl}\u003eGo to Qux 1\u003c/a\u003e\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femilte%2Fnamed-routes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femilte%2Fnamed-routes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femilte%2Fnamed-routes/lists"}