Primitives

useNavigate

Edit this page

Retrieves the method which accepts a path to navigate to and an optional object with the following options:

  • resolve (boolean, default true): resolve the path against the current route
  • replace (boolean, default false): replace the history entry
  • scroll (boolean, default true): scroll to top after navigation
  • state (any, default undefined): pass custom state to location.state
const navigate = useNavigate();
if (unauthorized) {
navigate("/login", { replace: true });
}
Report an issue with this page