DEV Community

loading...

Discussion on: Introduction to React Router

Collapse
djangotricks profile image
Aidas Bendoraitis • Edited

I learned about Routers just a couple of weeks ago. One thing worth mentioning is that <BrowserRouter> creates URLs like "example.com/hello/world" whereas <HashRouter> creates URLs like "example.com/#/hello/world".

The <BrowserRouter> is changing the URL paths dynamically using history API. When using <BrowserRouter>, your server should reflect all paths what the frontend allows to access. Otherwise you would get 404 errors when some page is refreshed.

On the other hand, the <HashRouter> is useful when you have a single page application or a single page website component. All the paths of <HashRouter> stay under the same path, only the hash part changes.

Collapse
aurelkurtula profile image
aurel kurtula Author

That's cool.

Thanks so much