Summary
Allow an index route such as / to expose a named typed-path node, so applications can write paths.index instead of calling the root builder with paths().
Current behavior
const Router = createRouter({
routes: [
{ path: "/", component: Home },
{ path: "/about", component: About },
],
});
const { paths } = Router;
paths(); // "/"
paths.about; // "/about"
paths.index; // TypeScript error; the runtime proxy represents "/index"
Static path nodes have descriptive property names, but the root/index route is represented by calling the path proxy itself. This makes a navigation vocabulary such as paths.index, paths.about, and paths.settings impossible without maintaining a separate application-level alias map.
Desired API
A route should be able to opt into a named path node whose value still comes from its actual path:
The exact route configuration API is open for discussion. Collision-safe possibilities include explicit naming:
{ path: "/", name: "index", component: Home }
or explicit index metadata:
{ path: "/", index: true, component: Home }
An explicit convention seems preferable to globally treating .index as a no-op segment, since applications may have a real /index route.
Design considerations
- Keep the runtime proxy and
RoutePaths inference aligned.
- Preserve access to literal
/index routes without ambiguity.
- Consider nested index routes, for example
paths.users(id).index producing /users/:id.
- Preserve base-path and hash-history rendering behavior.
- Keep
paths() working for backward compatibility.
- Ideally allow names other than
index if the underlying feature is named routes rather than an index-only special case.
Motivation
This keeps links, redirects, and navigation calls on one typed, semantic path vocabulary without requiring manually maintained aliases:
<a href={paths.index}>Home</a>
<a href={paths.about}>About</a>
Summary
Allow an index route such as
/to expose a named typed-path node, so applications can writepaths.indexinstead of calling the root builder withpaths().Current behavior
Static path nodes have descriptive property names, but the root/index route is represented by calling the path proxy itself. This makes a navigation vocabulary such as
paths.index,paths.about, andpaths.settingsimpossible without maintaining a separate application-level alias map.Desired API
A route should be able to opt into a named path node whose value still comes from its actual path:
The exact route configuration API is open for discussion. Collision-safe possibilities include explicit naming:
or explicit index metadata:
An explicit convention seems preferable to globally treating
.indexas a no-op segment, since applications may have a real/indexroute.Design considerations
RoutePathsinference aligned./indexroutes without ambiguity.paths.users(id).indexproducing/users/:id.paths()working for backward compatibility.indexif the underlying feature is named routes rather than an index-only special case.Motivation
This keeps links, redirects, and navigation calls on one typed, semantic path vocabulary without requiring manually maintained aliases: