{"id":15675436,"url":"https://github.com/scriptedalchemy/next-known-route","last_synced_at":"2025-05-06T21:45:16.359Z","repository":{"id":38813044,"uuid":"494160536","full_name":"ScriptedAlchemy/next-known-route","owner":"ScriptedAlchemy","description":"Check if a url is a known route to a next.js application ahead of time","archived":false,"fork":false,"pushed_at":"2023-12-15T02:57:37.000Z","size":26,"stargazers_count":13,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-14T12:54:14.988Z","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/ScriptedAlchemy.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":"2022-05-19T17:05:31.000Z","updated_at":"2024-02-15T18:17:22.000Z","dependencies_parsed_at":"2023-12-15T03:47:47.655Z","dependency_job_id":"42bfbb05-1404-492c-924a-f9fb52337981","html_url":"https://github.com/ScriptedAlchemy/next-known-route","commit_stats":{"total_commits":23,"total_committers":2,"mean_commits":11.5,"dds":0.04347826086956519,"last_synced_commit":"11c1bd5de71e7ea92214d271d7b591f61deb64fa"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScriptedAlchemy%2Fnext-known-route","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScriptedAlchemy%2Fnext-known-route/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScriptedAlchemy%2Fnext-known-route/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScriptedAlchemy%2Fnext-known-route/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ScriptedAlchemy","download_url":"https://codeload.github.com/ScriptedAlchemy/next-known-route/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252776450,"owners_count":21802460,"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-10-03T16:00:09.399Z","updated_at":"2025-05-06T21:45:16.336Z","avatar_url":"https://github.com/ScriptedAlchemy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# next-known-route\nCheck if a url is a known route to a next.js application ahead of time.\n\nhttps://www.npmjs.com/package/next-known-route\n\n# Use Case\nWhy do you need this? Next does not offer a way to know if a url matches a known route with the application.\nThe only way to do it out the box is to try and preload the route, which is wasteful \u0026 only works on the client. \n\n- Understanding internal vs external links during render or elsewhere in your application (like utils)\n- SEO - no follow links to external sources.\n- Any feature that requires a page manifest lookup.\n- Dynamic navigation and route expressions matching.\n\nNo third party dependencies, this is all made possible by using internal parts of next router.\n\n# Usage:\n\nIn `_app` add the following and return it from `getInitialProps`\n\n```js\nimport { getRouteManifest, isKnownRoute } from 'next-known-route'\n\nconst MyApp = ()=\u003e{\n    const internalRoute = isKnownRoute('/') // or whatever path you want to check aganst. Returns true|false\n    return (\u003cmain/\u003e)\n}\n\nMyApp.getInitialProps = async (appContext) =\u003e {\n    const appProps = await App.getInitialProps(appContext);\n\n    const props = {\n        ...appProps,\n        knownRoutes: getRouteManifest()  // returns ['/_app','/','/[...slug]']\n    };\n    return props\n}\n```\n\n## Features\n- Works on server and client\n- No external libraries needed, only 50 LOC\n- `getRouteManifest` accepts an array of additional path expressions to match against. \n\nContributions are welcome. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscriptedalchemy%2Fnext-known-route","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscriptedalchemy%2Fnext-known-route","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscriptedalchemy%2Fnext-known-route/lists"}