useNavigate Hook in React

From the TanStack Router cheat sheet · Navigation & Links · verified Jul 2026

useNavigate Hook

Programmatic navigation

typescript
import { useNavigate } from '@tanstack/react-router'

const navigate = useNavigate()

navigate({ to: '/posts' })

navigate({
  to: '/posts/$postId',
  params: { postId: '123' }
})
💡 Use for programmatic navigation
⚡ Type-safe params and search
🔍 Supports relative paths (./edit, ..)
🎯 replace option for history control
navigateprogrammatichook

More React tasks

Back to the full TanStack Router cheat sheet