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 });
}

If you are inside of a cache or action function you will instead want to use redirect or reload.

Report an issue with this page