Skip to content


Type declaration
declare function useNavigate(): NavigateFunction;

interface NavigateFunction {
    to: To,
    options?: { replace?: boolean; state?: any }
  ): void;
  (delta: number): void;

The useNavigate hook returns a function that lets you navigate programmatically, for example after a form is submitted. If using replace: true, the navigation will replace the current entry in the history stack instead of adding a new one.

import { useNavigate } from "react-router-dom";

function SignupForm() {
  let navigate = useNavigate();

  async function handleSubmit(event) {
    await submitForm(;
    navigate("../success", { replace: true });

  return <form onSubmit={handleSubmit}>{/* ... */}</form>;

The navigate function has two signatures:

  • Either pass a To value (same type as <Link to>) with an optional second { replace, state } arg or
  • Pass the delta you want to go in the history stack. For example, navigate(-1) is equivalent to hitting the back button.