I have googled quite some bit, but I didn't find a clear answer to the following question: What is the difference between hashHistory and browserHistory in react-router?
The basic difference is that the hashHistory uses URLs like: http://myurl.com/#page/another_page/another_page
With BrowserHistory you get normal urls (no hash): http://myurl.com/page/another_page/another_page
First difference:
They are using different WEB APIs.
<HashRouter>
uses and reads the hash from URL,
<BrowserRouter>
uses window.history
WEB API.
Second difference:
<HashRouter>
is used for static one-page website. Ideal for browser based projects.
<BrowserRouter>
is used for dynamic website. Should be used when you have a server that will handle dynamic requests (knows how to respond to any possible URL).
I don't think the question was asking for differences in the format, but rather technical. Hence sharing this answer here with a technical difference: https://stackoverflow.com/a/42157741/2445694
Basically the browser don't send the url after the #
So suppose that a website restricted areas for members and admins. A user navigates to /member, and is prompted for logging in. However the server won't know if the user was trying to access /admin or /member before getting on the log in page, so after logging in the server don't know where to redirect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With