useNavigate
The useNavigate
hook imperatively navigates between routes.
Example code
Anchor link to section titled "Example code"
Return value
Anchor link to section titled "Return value"The useNavigate
hook returns a function which accepts the following values:
Name | Description |
---|---|
path | The path you want to navigate to. |
options | The options for the configuration object: replace , reloadDocument , clientState , scroll . For more information on the options, refer to the Link component. |
Considerations
Anchor link to section titled "Considerations"- Consider using the
useNavigate
hook only where appropriate. Generally, you should use theLink
component instead, because it provides standard browser accessibility functionality, likecmd+click
and right-click to open. - The
useNavigate
hook is only available in client components.