T
TanStack2y ago
quickest-silver

how to automatically redirect a user to a subpage?

I have a route named schedule, and I want that by default it would move the user to schedule/tires, the index schedule page has a nav with 2 links to schedule/tires and schedule/orders, and an outlet.
1 Reply
ratty-blush
ratty-blush2y ago
You can use <Navigate />, that's the way React Router does it as well.
function Component() {
return <Navigate to="**/schedule/tires" />
}
function Component() {
return <Navigate to="**/schedule/tires" />
}
You may also need a layout for these nav links. https://tanstack.com/router/latest/docs/framework/react/guide/navigation
Navigation | TanStack Router Docs
Everything is Relative Believe it or not, every navigation within an app is relative, even if you aren't using explicit relative path syntax (../../somewhere). Any time a link is clicked or an imperative navigation call is made, you will always have an origin path and a destination path which means you are navigating from one route to another ...

Did you find this page helpful?