How to remove the hash from the url in react-router

Did you try the browserHistory option ? You will be able also to refresh the page from the browser or specify a url of one of existing routes and land on the right page.

import { Router, Route, browserHistory } from 'react-router';

ReactDOM.render((
 <Router history={browserHistory}>
    <Route path="https://stackoverflow.com/" component={MasterPage}>
      <IndexRoute component={LoginPage} />
      <Route path="/search" component={SearchPage} />
      <Route path="/login" component={LoginPage} />
      <Route path="/payment" component={PaymentPage} />
    </Route>
  </Router>),
    document.getElementById('app-container'));

Moreover hashHistory is not for production use considering the react-router github doc.

https://github.com/ReactTraining/react-router/blob/master/docs/guides/Histories.md#browserhistory

Should I use hashHistory?

Hash history works without configuring your server, so if you’re just
getting started, go ahead and use it. But, we don’t recommend using it
in production, every web app should aspire to use browserHistory

Leave a Comment