You can use the replaceState method on the history API to remove the hash.
The replaceState() method modifies the current history entry, replacing it with the state objects, title, and URL passed in the method parameters. This method is particularly useful when you want to update the state object or URL of the current history entry in response to some user action.
To remove the hash you can use −
history.replaceState(null, null, ' ');