MENU
<Navigate>
With <Navigate> you can redirect your user to another URL by rendering the component – typically as the "element" of whichever <Route> you want to redirect away from. The old "from" attribute is gone along with it, since <Navigate> no longer does any matching of its own.
| Attribute | Description |
|---|---|
| to | destination path string, or a partial Path object ({ pathname, search, hash }) |
| replace | if true, replaces the current history entry instead of pushing a new one onto it |
| state | a value to associate with the new location, readable later via useLocation().state |
Note the default flipped from React Router 5: the old <Redirect> replaced the current entry by default (with a "push" attribute to opt into pushing instead). <Navigate> instead pushes a new entry by default, exactly like useNavigate()'s navigate() function – pass "replace" explicitly to get the old default-replace behavior back.