useNavigate is a React hook that provides programmatic navigation within your AppShell application. It’s re-exported from react-router v7 and is essential for navigating between pages in response to user actions.
Usage
Signature
Examples
Basic Navigation
Navigate with Replace
Usereplace: true to replace the current history entry instead of adding a new one:
Navigate with State
Pass data to the destination route using thestate option:
Navigate Back
Use negative numbers to navigate backward in history:Dynamic Routes with Params
Type-Safe Navigation with Generated Routes
When using file-based routing with the Vite plugin, you can generate type-safe route helpers:See Type-Safe Navigation for setup instructions.
Common Patterns
Conditional Navigation
Navigation with Confirmation
Comparison with Link Component
Related Hooks
useLocation- Access current location objectuseParams- Access route parameters
See Also
- Routing and Navigation Guide
- Link Component - React Router v7 documentation