![]() |
VOOZH | about |
React Router is a ReactJS Library used for handling the navigation and routing in a web application. 'HashRouter' is a component in the react-router-dom library. It is used for implementing client-side routing in a React Application.
There are some common features in HashRouter that is explained here.
HashRouter | BrowserRouter |
|---|---|
Uses URLs with a hash symbol eg (/#/about) | Uses cleaner URL without a hash ( eg: '/about') |
It can uses in simpler application or static site deployments | Suitable for more complex applications with server-side rendering support |
import {HashRouter} from 'react-router-dom' ; | import {BrowserRouter} from 'react-router-dom' |
Step 1: Set up React project using the command
npx create-react-app clientStep 2: Navigate to the project folder using
cd clientStep 3: Installing the required packages:
npm install react-router-domStep 4: Create the required files and write the following code in respective files.
Output