{"id":19282461,"url":"https://github.com/4catalyzer/found-named-routes","last_synced_at":"2025-04-22T01:31:48.763Z","repository":{"id":14064754,"uuid":"75878812","full_name":"4Catalyzer/found-named-routes","owner":"4Catalyzer","description":"Named routes support for found","archived":false,"fork":false,"pushed_at":"2024-10-10T16:04:28.000Z","size":595,"stargazers_count":5,"open_issues_count":11,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-12T20:37:15.854Z","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/4Catalyzer.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-07T21:52:30.000Z","updated_at":"2020-12-14T11:00:33.000Z","dependencies_parsed_at":"2023-01-13T17:46:43.535Z","dependency_job_id":"f2fb153f-a925-47f9-8186-382e89095f35","html_url":"https://github.com/4Catalyzer/found-named-routes","commit_stats":{"total_commits":202,"total_committers":10,"mean_commits":20.2,"dds":0.5841584158415842,"last_synced_commit":"65f318108f585e530e89c1b136c07482414f0802"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4Catalyzer%2Ffound-named-routes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4Catalyzer%2Ffound-named-routes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4Catalyzer%2Ffound-named-routes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4Catalyzer%2Ffound-named-routes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/4Catalyzer","download_url":"https://codeload.github.com/4Catalyzer/found-named-routes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223886214,"owners_count":17219696,"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-11-09T21:26:58.669Z","updated_at":"2024-11-09T21:26:59.230Z","avatar_url":"https://github.com/4Catalyzer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Found Named Routes\n\nNamed route support for [Found](https://github.com/4Catalyzer/found). Inspired by [use-named-routes](https://github.com/taion/use-named-routes).\n\n## Usage\n\nPass your route configuration into `createNamedRoutesMiddleware`, then pass the middleware into `historyMiddlewares` when creating your router.\n\n```js\nimport { createBrowserRouter, makeRouteConfig, Route } from 'found';\nimport { createNamedRoutesMiddleware } from 'found-named-routes';\n\nconst routeConfig = makeRouteConfig(\n  \u003cRoute path=\"/\"\u003e\n    \u003cRoute name=\"widgets\" path=\"widgets\" component={WidgetsPage}\u003e\n      \u003cRoute name=\"widget\" path=\":widgetId\" component={WidgetPage} /\u003e\n    \u003c/Route\u003e\n  \u003c/Route\u003e,\n);\n\nconst namedRoutesMiddleware = createNamedRoutesMiddleware(routeConfig);\n\nconst BrowserRouter = createBrowserRouter({\n  routeConfig,\n  // Include queryMiddleware to preserve the default middlewares.\n  historyMiddlewares: [namedRoutesMiddleware, queryMiddleware],\n});\n```\n\nNote that `createNamedRoutesMiddleware` expects an object route configuration; when using JSX routes, make sure you pass in the output of `makeRouteConfig`.\n\nYou can then use either route names or objects with name and optionally params:\n\n```js\nrouter.push('widgets');\nrouter.push({ name: 'widget', params: { widgetId: '1' } });\n```\n\nor using links:\n\n```js\n\u003cLink to=\"widgets\"\u003eTo widgets\u003c/Link\u003e\n\u003cLink to={{ name: 'widget', params: { widgetId: '1' } }}\u003eTo widget 1\u003c/Link\u003e\n```\n\nThis middleware will not treat location strings as route names when the location starts with `/` or when the location string contains `://`, as it assumes that the former are absolute paths and that the latter are absolute URLs.\n\n```js\nhistory.push('/widgets/1');\n\n\u003cLink to=\"/widgets/1\"\u003eTo widget 1\u003c/Link\u003e;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4catalyzer%2Ffound-named-routes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F4catalyzer%2Ffound-named-routes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4catalyzer%2Ffound-named-routes/lists"}