In react-router-dom v6 we can call navigate(-1) in order to go one screen back. but what I want to achieve is a kind of navigate(-1) which removes the current URL from the stack as well.
So the purpose is to have a disabled forward button in the browser after the user has gone one screen back.
like:
Note that I also tried replacing the current URL with the previous one but it's not a good solution because if the user clicks on the back button they will remain on the same screen which is weird.
You are going to modify the history, and As far as I know, there's no way to delete a history entry (or state).
One way I've been looking into is to handle the history yourself in JavaScript with onpopState listener
https://developer.mozilla.org/en-US/docs/Web/API/History_API#examples