Export a type that describes all available routes. #378
ryanstaniforth
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
Using {([
['/', 'Home'],
['/users', 'Users'],
] as const).map(([to, label]) => (
<router.Link
key={to}
to={to}
>
{label}
</router.Link>
))} |
Beta Was this translation helpful? Give feedback.
2 replies
-
Another use case I have for this is when I create a component that needs to accept a url. It would be really nice to have a way of passing around typed routes without having to pass around a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a use case where I'm building a navigation with some static known URLs. I don't want to repeat the markup, so I loop over a simple array of URLs and labels, as such:
For it to work with this library, I have to include
satisfies Array<['/' | '/users', string]>
so that therouter.Link
accepts the routes. This is great but I don't want to go around specifying'/' | '/users'
. This is going to grow over time and needs maintaining alongside my defined route config.So my idea is to have an exported type from the router or route config such as
AvailableRoutes
that I can use in place.Beta Was this translation helpful? Give feedback.
All reactions