Featured Article

Master React Router Framework Mode: Ultimate Tutorial for Seamless Navigation

Kenneth Jul 13, 2026

Are you looking to build multi-page web applications using React? One of the key components to achieve this is the React Router framework. It's a powerful tool that enables navigation and routing within your application. In this tutorial, we'll guide you through the basics of React Router in both the hash and browser route modes.

React Router Crash Course
React Router Crash Course

Before we dive in, ensure you have a basic understanding of React and have set up a new React project. If not, we recommend checking out the official React documentation for a quick start.

How to set up user authentication using React, Redux, and Redux Saga
How to set up user authentication using React, Redux, and Redux Saga

Setting Up React Router

First, let's install React Router in your project. You'll need both the core library and the DOM router. You can do this with npm:

React Tutorial 15 - How to Creating a custom 404 Page with React Routers
React Tutorial 15 - How to Creating a custom 404 Page with React Routers

    `npm install react-router-dom`

Basic Importing and Wrapping

a router and modem diagram with instructions for how to properly reboot a router
a router and modem diagram with instructions for how to properly reboot a router

Once installed, you can import Router, Route, and Link from 'react-router-dom' in your entry file (usually App.js). Wrap your entire application with the BrowserRouter or HashRouter component depending on your desired routing mode.

    `import { BrowserRouter as Router, Route, Link } from 'react-router-dom';`

Routing Modes: Hash vs Browser

Deploying a React app with React-Router and an Express Backend
Deploying a React app with React-Router and an Express Backend

React Router supports two routing modes: hash and browser. The hash mode is useful when you're working on a single-page application that doesn't have a server-side routing configuration. It uses the hash part of the URL (e.g., #/) for routing.

Browser mode, on the other hand, is used when you have a server capable of handling different paths (e.g., example.com/home). It doesn't use the hash part of the URL, making it cleaner and more natural.

Configuring Routes

Restart Router Weekly: Fix Slow Wi‑Fi in 2 Minutes + Set an Auto Reboot
Restart Router Weekly: Fix Slow Wi‑Fi in 2 Minutes + Set an Auto Reboot

Now that we've set up the necessary imports and routing mode, let's configure some routes. Surround your Route components with the Router component.

Here's a simple example using BrowserRouter:

Getting started with create-react-app, Redux, React Router & Redux Thunk
Getting started with create-react-app, Redux, React Router & Redux Thunk
Todo App in React | Programming Fields
Todo App in React | Programming Fields
CQRS + Event Sourcing – Step by Step | Learn CQRS and Event Sourcing
CQRS + Event Sourcing – Step by Step | Learn CQRS and Event Sourcing
DIY Projects Ideas
DIY Projects Ideas
the different types of ports in networked devices are shown on this page, with information about them
the different types of ports in networked devices are shown on this page, with information about them
a yellow background with the words, why use client - side routing?
a yellow background with the words, why use client - side routing?
A Simple React Router v4 Tutorial
A Simple React Router v4 Tutorial
How to Use a Router for Beginners
How to Use a Router for Beginners
Getting started with create-react-app, Redux, React Router & Redux Thunk
Getting started with create-react-app, Redux, React Router & Redux Thunk
```````````

Nested Routing

You can create nested routes by wrapping Route components inside other Route components. This is useful for creating complex web applications with many pages.

NavLink for Active Class

To highlight the active route in your menu, use the NavLink component instead of Link. It'll apply an 'active' class to the currently active link.

    `Home`

There you have it! You now know how to set up and use React Router in both hash and browser route modes. Experiment with nested routing and dynamic route parameters to really understand its power.

The React ecosystem is constantly evolving, so keep an eye on the official documentation for the latest updates and features. Happy coding!