Question · Next.js course · Module 2: Routing and Layouts
router.push vs router.replace
How does router.replace() differ from router.push() from the useRouter hook?
Answer options
- replace replaces the current entry in the browser history, while push adds a new one
- replace reloads the whole page, while push does not
- replace only works in Server Components
- push does not change the URL
Show the answer
Correct answer:
- replace replaces the current entry in the browser history, while push adds a new one