useRouter
The hook from next/navigation that lets Client Components navigate and refresh in code.
In more detail
router.push('/login') navigates, router.back() goes back and router.refresh() re-fetches the current route from the server. It only works in Client Components.
Related terms
- router.refresh() — A method that clears the Router Cache for the current route and asks the server for a fresh render, keeping client state.
- Client Component — A component whose code is also sent to the browser so it can use state, effects and event handlers.
Taught in
- Router Cache: In-Memory Client Prefetch Semantics — Next.js 15 & Modern App Router Architecture