BrowserRouter

It uses history API, i.e. it's unavailable for legacy browsers (IE 9 and lower and contemporaries). Client-side React application is able to maintain clean routes like example.com/react/route but needs to be backed by web server. Usually this means that web server should be configured for single-page application, i.e. same index.html is served for /react/route path or any other route on server side. On client side, window.location.pathname is parsed by React router. React router renders a component that it was configured to render for /react/route.

Additionally, the setup may involve server-side rendering, index.html may contain rendered components or data that are specific to current route.

HashRouter

It uses URL hash, it puts no limitations on supported browsers or web server. Server-side routing is independent from client-side routing.

Backward-compatible single-page application can use it as example.com/#/react/route. The setup cannot be backed up by server-side rendering because it's / path that is served on server side, #/react/route URL hash cannot be read from server side. On client side, window.location.hash is parsed by React router. React router renders a component that it was configured to render for /react/route, similarly to BrowserRouter.

Most importantly, HashRouter use cases aren't limited to SPA. A website may have legacy or search engine-friendly server-side routing, while React application may be a widget that maintains its state in URL like example.com/server/side/route#/react/route. Some page that contains React application is served on server side for /server/side/route, then on client side React router renders a component that it was configured to render for /react/route, similarly to previous scenario.

Answer from Estus Flask on Stack Overflow
🌐
React Router
reactrouter.com › api › declarative-routers › HashRouter
HashRouter | React Router
function HashRouter({ basename, children, unstable_useTransitions, window, }: HashRouterProps) Application basename · <Route> components describing your route configuration · Control whether router state updates are internally wrapped in React.startTransition.
Top answer
1 of 11
259

BrowserRouter

It uses history API, i.e. it's unavailable for legacy browsers (IE 9 and lower and contemporaries). Client-side React application is able to maintain clean routes like example.com/react/route but needs to be backed by web server. Usually this means that web server should be configured for single-page application, i.e. same index.html is served for /react/route path or any other route on server side. On client side, window.location.pathname is parsed by React router. React router renders a component that it was configured to render for /react/route.

Additionally, the setup may involve server-side rendering, index.html may contain rendered components or data that are specific to current route.

HashRouter

It uses URL hash, it puts no limitations on supported browsers or web server. Server-side routing is independent from client-side routing.

Backward-compatible single-page application can use it as example.com/#/react/route. The setup cannot be backed up by server-side rendering because it's / path that is served on server side, #/react/route URL hash cannot be read from server side. On client side, window.location.hash is parsed by React router. React router renders a component that it was configured to render for /react/route, similarly to BrowserRouter.

Most importantly, HashRouter use cases aren't limited to SPA. A website may have legacy or search engine-friendly server-side routing, while React application may be a widget that maintains its state in URL like example.com/server/side/route#/react/route. Some page that contains React application is served on server side for /server/side/route, then on client side React router renders a component that it was configured to render for /react/route, similarly to previous scenario.

2 of 11
83

SERVER SIDE: HashRouter uses a hash symbol in the URL, which has the effect of all subsequent URL path content being ignored in the server request (ie you send "www.mywebsite.com/#/person/john" the server gets "www.mywebsite.com". As a result the server will return the pre # URL response, and then the post # path will be handled (or parsed) by your client side react application.

CLIENT SIDE: BrowserRouter will not append the # symbol to your URL, however will create issues when you try to link to a page or reload a page. If the explicit route exists in your client react app, but not on your server, reloading and linking(anything that hits the server directly) will return 404 not found errors.

People also ask

What is the difference between Router and BrowserRouter in React?
In React Router, `` is the standard library component used as a foundation for routing, while Browser Router is a specific implementation that relies on the HTML5 history API for clean URLs. Browser Router requires proper server configuration to prevent 404 errors when users refresh a page. In contrast, React HashRouter manages route path using the URL hash, making it suitable for non-browser environments and situations where server-side routing is unavailable.
🌐
dhiwise.com
dhiwise.com › blog › design-converter › how-to-use-react-hashrouter-for-smooth-routing
React HashRouter Guide: Set Up and Use It Easily
Is the React Router deprecated?
No, React Router is not deprecated. It remains the most commonly used router for handling routing in React applications. The library continuously receives updates to improve client-side routing, support dynamic routing, and provide better integration with modern web applications. However, older APIs such as **Switch** and some lifecycle methods have been replaced with **Routes** and **useNavigate** to enhance flexibility. React Router Dom is actively maintained and widely adopted for both single-page applications and complex web applications.
🌐
dhiwise.com
dhiwise.com › blog › design-converter › how-to-use-react-hashrouter-for-smooth-routing
React HashRouter Guide: Set Up and Use It Easily
🌐
GeeksforGeeks
geeksforgeeks.org › reactjs › hashrouter-in-react-router
HashRouter in React Router - GeeksforGeeks
July 23, 2025 - 'HashRouter' is a component in the react-router-dom library. It is used for implementing client-side routing in a React Application. The 'HashRouter' uses the hash portion ('#') of the URL to manage the client-side routing.
🌐
React Router
reactrouter.com › 6.30.3 › router-components › hash-router
HashRouter v6.30.3 | React Router
In these situations, <HashRouter> makes it possible to store the current location in the hash portion of the current URL, so it is never sent to the server. import * as React from "react"; import * as ReactDOM from "react-dom"; import { HashRouter } from "react-router-dom"; ReactDOM.render( <HashRouter> {/* The rest of your app goes here */} </HashRouter>, root );
🌐
Upbeatcode
upbeatcode.com › react › using-hashrouter-with-react-definitive-guide
Using Hashrouter With React - Definitive Guide | Upbeat Code
A Router that uses the hash portion of the URL (i.e. window.location.hash) to keep your UI in sync with the URL. (source: React Router) Let's consider a simple website that consists of 2 pages. ... To implement this website using a HashRouter, we'll do the following.
Find elsewhere
🌐
CodeSandbox
codesandbox.io › s › react-hashrouter-5puuc
React HashRouter - CodeSandbox
August 11, 2021 - React HashRouter by learning-zone using react, react-dom, react-router-dom, react-scripts
Published   Aug 11, 2021
Author   learning-zone
🌐
Rafaelmalgor
rafaelmalgor.github.io › blog › 2020 › 04 › 09 › hasrouter.html
React HashRouter: how to avoid headaches - The Undefined Void
April 9, 2020 - The HashRouter component is included on the React Router library ready to be used and you barely need to change your code to use it.
🌐
DhiWise
dhiwise.com › blog › design-converter › how-to-use-react-hashrouter-for-smooth-routing
React HashRouter Guide: Set Up and Use It Easily
March 19, 2025 - It allows single-page apps to navigate between views without a full page reload. React Router is one of the most popular libraries for client-side routing and has several ways to manage routing.
🌐
Reddit
reddit.com › r/webdev › what is the difference between browserrouter and hashrouter in react router?
r/webdev on Reddit: What is the difference between BrowserRouter and HashRouter in react router?
May 6, 2024 -

So I have deployed my build on gh pages and couldnt navigate through my app properly until I switched from BrowserRouter to HashRouter, is it bad? Will I have to swtich it back to BrowserRouter when I'll deploy it on another hosting?

🌐
Wanago
wanago.io › home › comparing the hashrouter and the browserrouter in react applications
Comparing the HashRouter and the BrowserRouter in React applications
April 19, 2021 - There is more than one way of managing routes with modern single-page applications (SPA). In this article, we look into how hash routing works. We also explain the more modern approach to routing using the history API and the browser router. The examples will use the React Router library.
🌐
GitHub
btholt.github.io › complete-intro-to-react › react-router
Complete Intro to React
Make sure ESLint isn't yelling at you and that your app still works. It should appear pretty much the same to you. The HashRouter is a sort of hacky router which puts your route information into the hash of the URL (after the #). We'll use BrowserRouter later so we have nice URLs, but for now ...
🌐
DhiWise
dhiwise.com › post › browserrouter-vs-hashrouter-a-comprehensive-guide
BrowserRouter vs. HashRouter: Making the Right Choice
August 2, 2024 - However, it provides a better user ... performance on legacy browsers. HashRouter uses the hash portion of the URL (the part following the hash symbol) to keep your UI in sync with the URL....
🌐
GeeksforGeeks
geeksforgeeks.org › reactjs › reactjs-types-of-routers
React JS Types of Routers - GeeksforGeeks
HashRouter is a useful and simple router for React applications that rely on URL hashes for navigation, especially in environments where server-side routing is not available.
Published   March 26, 2020
🌐
Delft Stack
delftstack.com › home › howto › react › hashrouter component in react
The hashRouter Component in React | Delft Stack
March 11, 2025 - HashRouter is a routing component provided by the React Router library. It uses the hash portion of the URL (the part after the # symbol) to keep track of the user’s location within your application.
🌐
Upmostly
upmostly.com › home › tutorials › what is hash routing?
What is Hash Routing? - Upmostly
January 27, 2023 - Using the react-router-dom library, you can easily set up a hash router in your React app and provide a better user experience.
🌐
Medium
medium.com › @AbbasPlusPlus › understanding-the-three-types-of-routers-in-react-a4994c8c229d
Understanding the Three Types of Routers in React | by Mohammad Abbas | Medium
August 28, 2023 - import { BrowserRouter, Route } ... path="/about" component={About} /> </BrowserRouter> ); HashRouter uses the URL's hash portion to keep your UI in sync with the URL....