Skip to content Skip to sidebar Skip to footer

Nextjs: 404 Page Back Button Returns Back To 404 Page

I have a condition inside my lifecycle method of user Page such that if the user enters an URL with certain parameters such as somePage.com/user/1 will fetch the data of the user w

Solution 1:

Router.push will add the new URL into the history stack, however, Router.replace will redirect to the 404-page without adding a new URL entry into the history stack. So the back button will redirect to the last successful entry in the history stack, https://nextjs.org/docs/api-reference/next/router#routerreplace gives a clear example.


Post a Comment for "Nextjs: 404 Page Back Button Returns Back To 404 Page"