{"id":26912717,"url":"https://github.com/starlanestudios/react-router-tree","last_synced_at":"2026-04-07T07:44:23.285Z","repository":{"id":118921330,"uuid":"525106094","full_name":"StarlaneStudios/react-router-tree","owner":"StarlaneStudios","description":"Implement Next.js style routing in any Vite based react application","archived":false,"fork":false,"pushed_at":"2023-04-08T11:32:16.000Z","size":99,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-03T16:18:49.580Z","etag":null,"topics":["create-react-app","nextjs","pages","react","react-router","routing","typescript","vite","webpack"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-router-tree","language":"TypeScript","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/StarlaneStudios.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,"zenodo":null}},"created_at":"2022-08-15T19:03:38.000Z","updated_at":"2024-01-12T18:35:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"8b09146e-6273-48dc-8e7a-32e253adfa0c","html_url":"https://github.com/StarlaneStudios/react-router-tree","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/StarlaneStudios/react-router-tree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarlaneStudios%2Freact-router-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarlaneStudios%2Freact-router-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarlaneStudios%2Freact-router-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarlaneStudios%2Freact-router-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StarlaneStudios","download_url":"https://codeload.github.com/StarlaneStudios/react-router-tree/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarlaneStudios%2Freact-router-tree/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31504897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["create-react-app","nextjs","pages","react","react-router","routing","typescript","vite","webpack"],"created_at":"2025-04-01T15:34:34.372Z","updated_at":"2026-04-07T07:44:23.278Z","avatar_url":"https://github.com/StarlaneStudios.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cbr\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/StarlaneStudios/react-router-tree/main/.github/logo.svg\" height=\"164\"\u003e\n\u003c/p\u003e\n\n# React Router Tree\n\nImplement Next.js style page directories in your single page application. Supports React projects created using [Vite](https://vitejs.dev/) or [CRA](https://create-react-app.dev/) (or any other webpack implementation).\n\n# DEPRECATED ⚠️\nThis package is no longer actively maintained and has been superseded by [Sceptre](https://github.com/StarlaneStudios/sceptre).\n\n## Installation\n\nInstall the package using NPM\n\n```\nnpm install react-router-tree\n```\n\n## Page folder structure\n\nPages are defined using a folder structure in your application. Subfolders denote path segments, while pages map to `index.tsx` or `index.jsx` files. In react-router-tree, each page is given it's own directory, in which assets and styles can be placed, allowing for a clean and structured page setup.\n\n## Exporting pages\n\nEach page is expected to contain a default export of it's `RouteObject`. For TypeScript users a `defineRoute` helper function is included. The `path` property will automatically be populated when parsing the tree, so it may be omitted.\n\n```tsx\nimport { defineRoute } from \"react-router-tree\";\n\nfunction IndexPage() {\n\treturn (\n\t\t\u003cdiv\u003e\n\t\t\tPage content\n\t\t\u003c/div\u003e\n\t)\n}\n\nexport default defineRoute({\n\telement: \u003cIndexPage /\u003e\n});\n```\n\n### URL Parameters\n\nParameters can be defined by using `[name]` as folder name. This will automatically translate into `:name` when building routes.\n\nWe also support a other parameter type: `...` which will match any path segment.\n\n### Index mapping\n\nFolders named `@` will map to the index page of the parent directory.\n\n### Parent pages\n\nYou can add a parent pages by making a folder named `_` anywhere in your file tree. Parent pages are responsible for placing an `\u003cOutlet /\u003e` where child routes will be rendered. Routes can be parented any number of times, each rendering in its closest parent outlet.\n\nVisual example:\n```\n/example/_\t\t\t\t- Responsible for rendering outlet 1\n/example/@\t\t\t\t- Rendered inside outlet 1\n/example/page/_\t\t\t- Rendered inside outlet 1 and responsible for rendering outlet 2\n/example/page/@\t\t\t- Rendered inside outlet 2\n/example/page/child \t- Rendered inside outlet 2\n```\n\n## Alternative paths\n\nThe route object returned from a page allows defining a list of alternative routes that can be used to reach the page. These alternative paths are relative to the route itself and share the same meta.\n\nExample:\n```tsx\nexport default defineRoute({\n\telement: \u003cHelpPage /\u003e,\n\talternatives: [\n\t\t{ path: 'instructions' },\n\t\t{ path: 'sub/path/:param' }\n\t]\n});\n```\n\n### Example folder structure\n\n```\npages/\n\t@/\n\t\tindex.tsx\n\t\tstyles.tsx\n\thelp/\n\t\tindex.tsx\n\t\tstyle.scss\n\tsettings/\n\t\t_/\n\t\t\tindex.tsx\n\t\toverview/\n\t\t\tindex.tsx\n\t\t[param]/\n\t\t\tindex.tsx\n\tfolder/\n\t\t_/\n\t\t\tindex.tsx\n\t\t[...]/\n\t\t\tindex.tsx\n\t\t\tstyle.scss\n```\n\nThe above example translates to the given routes\n\n```\n/\n/help\n/settings/overview\n/settings/:param\n/folder/*\n```\n\n## Usage\n```ts\n// Using vite:\nconst pageTree: RouteTree = {\n\tprefix: './pages',\n\troutes: import.meta.glob('./pages/**/index.tsx', { eager: true })\n};\n\n// Using Create React App:\nconst pageTree: RouteTree = {\n\tprefix: './',\n\troutes: require.context('./pages/', true, /\\index\\.tsx$/)\n};\n\n// Combine page trees into a single array of routes\nconst routes = buildRouteObjects(pageTree);\n```\n\n## Example\n\nAn example implementation can be found [here](https://github.com/StarlaneStudios/react-router-tree/tree/main/example).\n\n## Vindigo\n\nThis package was originally developed for use in [Vindigo](https://github.com/StarlaneStudios/vindigo), a free and open source task planner.\n\n## License\n\nreact-router-tree is licensed under [MIT](https://github.com/StarlaneStudios/react-router-tree/blob/main/LICENSE)\n\nCopyright (c) 2022-present, [Starlane Studios](https://starlane.studio/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarlanestudios%2Freact-router-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstarlanestudios%2Freact-router-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarlanestudios%2Freact-router-tree/lists"}