useNavigate hook imperatively navigates between routes.
Example codeAnchor link to section titled "Example code"
Return valueAnchor link to section titled "Return value"
useNavigate hook returns a function which accepts the following values:
|path||The path you want to navigate to.|
|options||The options for the configuration object:
ConsiderationsAnchor link to section titled "Considerations"
- Consider using the
useNavigatehook only where appropriate. Generally, you should use the
Linkcomponent instead, because it provides standard browser accessibility functionality, like
cmd+clickand right-click to open.
useNavigatehook is only available in client components.