React Router Basics: Multi-Page Navigation for a Brochure Website

Introduction to React Router and Brochure Websites
When building a modern website with React, you’ll quickly encounter the need for multi-page navigation. This is especially true for brochure websites—sites designed to showcase a business, product, or service with clear navigation between key pages like Home, About, Services, and Contact. While React is famous for creating single page applications (SPAs), React Router bridges the gap, enabling seamless navigation that feels multi-page, without full page reloads.
In this section, we’ll demystify what React Router is, why it matters for brochure websites, and how multi-page navigation works in React. By the end, you’ll see why React Router is the go-to tool for adding page-like navigation to your React projects.
What is React Router?
React Router is the standard routing library for React. It allows you to define multiple navigation paths ("routes") in your app, each leading to different components (pages) without reloading the entire page. This gives users the experience of navigating a traditional website, while you enjoy the performance and flexibility of a SPA.
React Router works by updating the browser’s URL and rendering the matching component instantly. This is achieved using special components like <BrowserRouter>, <Routes>, <Route>, and <Link>—you’ll meet these soon.
What is a Brochure Website?
A brochure website is a simple, informational site with a handful of pages. Think of a restaurant website with Home, Menu, Gallery, and Contact pages. The focus is on clear navigation, crisp content, and easy access to information—no complex user accounts or dashboards.
Why Use React Router for Brochure Websites?
React Router is ideal for brochure websites for several reasons:
- Simple navigation setup: Easily map URLs like
/aboutor/contactto React components. - Fast transitions: Users move between pages without reloads, making the site feel snappy.
- SEO-friendly (with extra setup): With additional tools, React Router can support server-side rendering for better search visibility.
- Component-based structure: Each page is simply a React component, keeping code organized.
Benefits of Multi-Page Navigation in React
- Improved user experience: Navigation is instant, with no flicker or loss of state.
- Scalable structure: Add more pages without rewriting navigation logic.
- Reusability: Share layout or navigation components across pages.
Is React Router Suitable for Brochure Websites?
Absolutely! Even if your site is only a few pages, React Router makes navigation simple and future-proof. If you ever expand your site, you won’t need to rethink your entire navigation system.
Key Questions Answered
- What is React Router and how does it work?
- It’s a set of components that map URLs to React components, enabling navigation in SPAs.
- Is React Router suitable for brochure websites?
- Yes. It’s perfect for simple sites with multiple pages.
- What are the benefits of using React Router?
- Fast navigation, organized code, and easy expansion.
What’s Next?
Now that you understand the why and what, let’s roll up our sleeves and set up your React development environment. This will put you in the perfect position to install React Router and start creating your brochure website.
Further Reading
- React Router Documentation — Official docs and conceptual overview.
- React Official Docs — Core concepts and best practices for React.
Setting Up Your React Development Environment
Before you can dive into React Router basics, you need a working React project. This section walks you step-by-step through setting up your environment—installing Node.js and npm, creating a new React app, understanding the folder structure, and running your development server. Whether you’re starting a new brochure website or want to follow along with a fresh project, these steps will get you ready.
1. Install Node.js and npm
Node.js is the JavaScript runtime you’ll use to run development tools, and npm (Node Package Manager) comes bundled with it. React and React Router are installed via npm.
To install Node.js and npm:
-
Download the recommended LTS version for your operating system.
-
Run the installer and follow the prompts.
-
Verify the installation by running these commands in your terminal:
node --version npm --versionYou should see version numbers for both.
2. Create a New React Application
The easiest way to start a React project is with Create React App—a toolkit that sets up everything you need in seconds.
To create a new React app:
-
Open your terminal and navigate to the folder where you want your project (e.g.,
~/projects). -
Run:
npx create-react-app brochure-websiteReplace
brochure-websitewith your preferred project name. -
When it finishes, go into your project folder:
cd brochure-website
3. Understand the Project Folder Structure
Here’s an overview of the key folders and files you’ll see:
public/: Static files likeindex.htmland images.src/: Source code for your React app (where you’ll spend most of your time).App.js: Main application component.index.js: Entry point that renders the app.
package.json: Lists dependencies and scripts.
4. Run the Development Server
To see your app in action, start the development server:
npm start
- Your browser should open to
http://localhost:3000/with the default React welcome screen. - The app will automatically reload as you make changes.
Quick Checklist
- Node.js and npm installed
- New React app created
- Project structure understood
- Development server running
You’re now ready to add React Router and transform your site into a real, multi-page brochure website.
Further Reading
- Node.js Official Site — Download and install Node.js and npm.
- Create React App Documentation — Details and advanced options for project setup.
Installing and Configuring React Router DOM
With your React project up and running, it’s time to bring in React Router DOM—the package that handles routing in browser-based React apps. This section guides you through installation, importing key components, and configuring your app to support navigation between pages.
1. Install React Router DOM via npm
Run the following command inside your project folder:
npm install react-router-dom@6
- This installs the latest stable version of React Router DOM (version 6 at the time of writing).
- The
react-router-dompackage provides all the core routing components for web apps.
2. Import React Router Components
To use React Router, you’ll need to import its components into your code. The most important ones for now are:
BrowserRouter: Enables routing in your app.RoutesandRoute: Define which components show up for which paths.
3. Wrap Your App with BrowserRouter
To activate routing, you must wrap your app in a <BrowserRouter> component. This is typically done in your src/index.js or src/main.jsx file, depending on your setup.
Example (src/index.js):
import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import App from './App';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
</React.StrictMode>
);
What does this do?
- It enables React Router throughout your app.
- Any routing components (like
Routes,Route,Link) inside<App />will now work.
4. Understand the Purpose of BrowserRouter
BrowserRouter is the core provider that keeps your app’s UI in sync with the browser’s URL. It uses the HTML5 history API—so when you navigate, the URL updates without a page reload.
- All your Route and Link components must be used inside a BrowserRouter.
- You only need one BrowserRouter at the root of your app.
Micro-Project: Test the Setup
To confirm everything is working:
-
Open
App.jsin yoursrc/folder. -
Add this code to try routing basics:
import { Routes, Route } from 'react-router-dom'; function Home() { return <h2>Home Page</h2>; } function About() { return <h2>About Page</h2>; } function App() { return ( <Routes> <Route path="/" element={<Home />} /> <Route path="/about" element={<About />} /> </Routes> ); } export default App; -
Visit
http://localhost:3000/(should show Home Page) andhttp://localhost:3000/about(should show About Page).
If you see these pages, React Router is working!
Further Reading
- React Router Quick Start — Step-by-step beginner guide.
- npm React Router DOM — Official npm package info and install instructions.
Understanding React Router’s Core Concepts
Before you craft a navigation menu or connect real pages, it’s crucial to grasp React Router’s foundational concepts. Let’s break down the essential components—Routes, Route, Link/NavLink, and how navigation works in a React single page application (SPA).
Routes and Route: Mapping Paths to Pages
<Routes>: Acts as a container for all your route definitions. Think of it as the “switchboard” that matches the current URL to a particular page/component.<Route>: Defines a single path and the component to show for that path.
Example:
<Routes>
<Route path="/" element={<Home />} />
<Route path="/about" element={<About />} />
<Route path="/services" element={<Services />} />
</Routes>
- When the URL is
/about, theAboutcomponent is rendered. - Each Route can map to any React component—pages, layouts, or even redirects.
Link and NavLink: Navigation Without Reloads
<Link to="/about">About</Link>: Renders an anchor tag (<a>) that updates the URL and renders the new page instantly, without a full reload.<NavLink>: Like Link, but adds styling when the link is "active" (matches the current URL)—ideal for navigation menus.
Example:
import { Link, NavLink } from 'react-router-dom';
function Navigation() {
return (
<nav>
<NavLink to="/" end>Home</NavLink> |
<NavLink to="/about">About</NavLink> |
<NavLink to="/services">Services</NavLink> |
<NavLink to="/contact">Contact</NavLink>
</nav>
);
}
- NavLink automatically applies an
activeclass to the current page link.
Navigation in a Single Page Application (SPA)
React Router enables true SPA behavior:
- No full page reloads. Only the components change, not the browser page.
- Preserves app state. Navigating between pages doesn’t lose component state or scroll position (unless you reset them intentionally).
- Faster experience. Since only part of the page updates, navigation feels instant.
The Role of Switch and Routes (v6+)
If you’ve seen older React Router tutorials, you might notice the Switch component. In React Router v6, Switch is replaced by Routes, which is more flexible and intuitive. Always use Routes with the latest version.
Common Pitfalls to Avoid
- Forgetting to wrap your app in BrowserRouter.
- Using
Switchwith v6+ (it won’t work!). - Not using
element={<Component />}in Route (v6+ syntax). - Misusing Link: using
<a href>causes a full reload, while<Link to>is SPA-friendly.
Checklist: Core React Router Components
-
<BrowserRouter>— Root provider -
<Routes>— Container for your routes -
<Route>— Maps URL to page/component -
<Link>and<NavLink>— SPA navigation
Further Reading
- React Router API Reference — Detailed docs on all React Router components (v6).
Planning the Structure of a Brochure Website
Before jumping into code, a little planning goes a long way. Let’s lay out the typical structure of a brochure website, map out which pages you’ll need, and design a navigation menu that makes sense for visitors.
1. Identify Common Pages
Most brochure websites have:
- Home: Welcome page
- About: Company or individual background
- Services/Products: What you offer
- Contact: How visitors can reach you
- (Optional) Gallery, Testimonials, FAQ, etc.
Example Page List:
/— Home/about— About Us/services— Our Services/contact— Contact
2. Map Out Navigation and Routing Paths
For each page, decide on the URL path and which React component will represent it.
| Path | Page Component |
|---|---|
/ | Home |
/about | About |
/services | Services |
/contact | Contact |
3. Visualize Website Structure as a Component Tree
A simple React component tree for a brochure site might look like:
App
├── NavigationMenu
├── Routes
│ ├── Home
│ ├── About
│ ├── Services
│ └── Contact
└── Footer
- App: Root component, contains navigation and routes.
- NavigationMenu: Links to main pages.
- Routes: Renders the correct page based on URL.
- Footer: (Optional) Site-wide footer.
4. Prepare a Navigation Menu Plan
A navigation menu is typically a horizontal bar at the top, with links to each page. Using React Router’s NavLink makes highlighting the active page easy.
Example Navigation Plan:
- Home | About | Services | Contact
Each link uses a <NavLink> with the corresponding path.
Mini-Project: Write Down Your Page Plan
Take a minute to jot down the pages you want for your brochure site and their URLs. For example:
/– Home/about– About/services– Services/contact– Contact
This plan will guide your Route setup in the next part.
What’s Next?
Now that you have a roadmap, you’re ready to implement multi-page navigation using React Router. In the next part, you’ll create page components, build the navigation menu, and wire everything together using the concepts and setup from Part 1.
Further Reading
- Smashing Magazine: Brochure Websites — Principles and layouts for effective brochure sites.
Building Pages and Routing with React Router
In Part 1, you laid the groundwork for your React brochure website and installed react-router-dom. Now, it's time to bring your brochure to life by creating individual pages—such as Home, About, Services, and Contact—and connecting them with React Router. This section walks you through building each page as a React component and wiring up the routes so visitors can seamlessly navigate your multi-page site.
By the end of this section, you'll have a working example of multi-page navigation using React Router basics, a crucial skill for any React website structure.
1. Create a Page Component for Each Section
Let's start by creating a folder for your page components, then add one file per page:
- Inside your
srcdirectory, create a new folder namedpages. - For each brochure page, create a separate file:
Home.jsAbout.jsServices.jsContact.js
Each file should export a functional component. For example:
// src/pages/Home.js
function Home() {
return (
<div>
<h1>Welcome to Our Brochure Website</h1>
<p>This is the home page. Explore our services and get to know us!</p>
</div>
);
}
export default Home;
Repeat similar structure for About, Services, and Contact pages. Keep the content simple for now—you can enhance it later.
2. Set Up Routes in Your Main App
With your page components ready, it's time to define routes. In your App.js (or wherever your main app component lives):
- Import the necessary router components:
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import Home from './pages/Home';
import About from './pages/About';
import Services from './pages/Services';
import Contact from './pages/Contact';
- Wrap your app content in a
<Router>and define routes with<Routes>and<Route>:
function App() {
return (
<Router>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/about" element={<About />} />
<Route path="/services" element={<Services />} />
<Route path="/contact" element={<Contact />} />
</Routes>
</Router>
);
}
export default App;
3. Understanding Path Mapping and Route Matching
- The
pathprop determines the URL segment that triggers each component. - The route with
path="/"matches the home page (the root of your site). - Sub-pages like
/about,/services, and/contactare mapped to their respective components. - React Router uses client-side routing, allowing fast, seamless navigation without full page reloads.
4. Testing Navigation Between Pages
You can temporarily navigate by manually typing URLs into the browser. Try visiting /, /about, /services, and /contact to confirm the right page loads each time.
Later, you'll add a navigation menu for user-friendly page switching.
Micro-Project: Add a 404 Page
For a professional touch, add a fallback route for undefined URLs:
// In App.js
<Route path="*" element={<div><h2>404 - Page Not Found</h2></div>} />
This ensures users who mistype a URL get a helpful message instead of a blank screen.
Further Reading
- React Router Tutorial: Adding Pages — Demonstrates adding and routing multiple pages.
Creating a Navigation Menu with React Router
Now that each page and its route are set up, let's build a navigation menu to allow users to move between pages with a single click. A well-designed menu is essential for any brochure website in React, ensuring a smooth user experience and reinforcing your site's structure.
This section uses Link and NavLink components from react-router-dom to create accessible, SPA-style links with active state styling.
1. Implement Navigation with Link and NavLink
- Create a new component for your navigation menu, e.g.,
Navbar.jsin thesrc/componentsfolder. - Import
LinkorNavLinkfromreact-router-dom:
import { NavLink } from 'react-router-dom';
- Structure your navbar:
// src/components/Navbar.js
import { NavLink } from 'react-router-dom';
function Navbar() {
return (
<nav>
<ul>
<li><NavLink to="/" end>Home</NavLink></li>
<li><NavLink to="/about">About</NavLink></li>
<li><NavLink to="/services">Services</NavLink></li>
<li><NavLink to="/contact">Contact</NavLink></li>
</ul>
</nav>
);
}
export default Navbar;
- The
endprop on the Home link ensures it only matches exactly/. NavLinkautomatically adds anactiveclass to the link when its route matches the current URL.
- Add your
Navbarto the main App layout, typically above the<Routes>:
import Navbar from './components/Navbar';
function App() {
return (
<Router>
<Navbar />
<Routes>
{/* routes here */}
</Routes>
</Router>
);
}
2. Style Active Navigation Links
To give users visual feedback on their current location, style the active link. You can use CSS:
/* App.css or Navbar.css */
nav ul {
list-style: none;
display: flex;
gap: 1.5rem;
}
nav a {
text-decoration: none;
color: #333;
font-weight: 500;
padding: 0.5em 1em;
border-radius: 4px;
}
nav a.active {
background: #007aff;
color: #fff;
}
Or, for more control, use the style or className prop as a function:
<NavLink to="/about" className={({ isActive }) => isActive ? 'active' : undefined}>
About
</NavLink>
3. Integrate Navigation into the Website Layout
- Place the
Navbarat the top of your page for consistent site-wide navigation. - Consider adding a
HeaderorLayoutcomponent to wrap your menu and page content—this will become more useful as your site grows (see Part 3).
4. Ensure Accessibility and Usability
- Use semantic HTML (
<nav>,<ul>,<li>) for your navigation. - Make sure the menu is keyboard-navigable and readable by screen readers.
- Use clear, descriptive link text.
Checklist: Accessible Navigation
- All links are keyboard accessible
- Active link is visually distinct
- Navigation uses semantic elements
- Test with a screen reader if possible
Further Reading
- React Router NavLink Docs — Explains how to use NavLink for navigation and active states.
Best Practices and Common Mistakes in React Router Navigation
Professional brochure websites built with React Router not only look good but are robust, maintainable, and easy to navigate. This section explores best practices for structuring your routes, as well as common mistakes that can trip up even experienced developers.
By following these guidelines, you'll create a React website routing structure that's both developer-friendly and user-friendly.
Best Practices for Route Organization
- Group related routes: Organize your page components in a logical folder structure (
src/pages,src/components). - Use clear, semantic paths: Keep paths lowercase and descriptive (e.g.,
/about, not/AboutUsPage). - Centralize routes: Define all main routes in one place (like your main
App.jsor a separateRoutes.js). - Add a catch-all route: Use
path="*"for 404 handling. - Prepare for scalability: As your site grows, consider using nested routes and layout components (see next section).
Common Mistakes and How to Avoid Them
- Using
<a href="...">for navigation: This causes full page reloads. Always useLinkorNavLinkfor internal links. - Incorrect path casing: Paths are case-sensitive. Use lowercase to avoid confusion.
- Forgetting the
exactorendprop: In older React Router versions, missingexactcould cause multiple matches. In v6+, useendon the root route to prevent unwanted matches. - Not handling non-existent routes: Failing to add a fallback (
path="*") means users may see a blank page. - Placing
<Routes>outside<Router>: Always wrap<Routes>inside<Router>.
Step-by-Step: Avoiding Common Routing Pitfalls
- Always use
<Link>or<NavLink>for navigation between pages. - Double-check your route paths for typos and case-sensitivity.
- Add a fallback route as the last route:
<Route path="*" element={<NotFound />} /> - Organize your components and routes for clarity and scalability.
When to Use Nested Routes
- If you have pages with their own sub-pages (e.g.,
/services/design,/services/consulting), nested routes keep your code organized. - For simple brochure sites, flat routes are fine—but plan for growth!
Ensuring SEO-Friendly Navigation
- Use descriptive, keyword-rich URLs (e.g.,
/about,/services/web-design). - Add
<title>, meta tags, and canonical URLs using React Helmet or similar libraries to ensure search engines understand your site structure. - For static hosting (like Netlify or Vercel), configure rewrites to support client-side routing (covered in the deployment section).
Further Reading
- React Router FAQ — Covers common issues and best practices for React Router.
- CSS-Tricks: React Router Tips — Practical tips and tricks for using React Router effectively.
Advanced: Nested Routes and Layout Components
Once your brochure website has the basics down, you can elevate its structure and maintainability with nested routes and shared layout components. This approach is ideal for real-world sites with sections that share headers, footers, or navigation, or that have sub-pages (like individual service descriptions).
This section will guide you through creating a reusable layout component and implementing nested routes in React Router.
1. Create a Reusable Layout Component
Let’s design a layout that wraps your content with a header (navigation), footer, and main content area.
// src/components/Layout.js
import Navbar from './Navbar';
function Layout({ children }) {
return (
<div>
<Navbar />
<main>{children}</main>
<footer>© {new Date().getFullYear()} Your Company</footer>
</div>
);
}
export default Layout;
However, React Router v6 introduces the <Outlet /> component for nested routing. Update your layout:
import { Outlet } from 'react-router-dom';
import Navbar from './Navbar';
function Layout() {
return (
<div>
<Navbar />
<main>
<Outlet />
</main>
<footer>© {new Date().getFullYear()} Your Company</footer>
</div>
);
}
export default Layout;
2. Implement Nested Routing for Subpages
Suppose your Services page has subpages like Web Design and Consulting. Structure your routes like this:
// In App.js
import Layout from './components/Layout';
import Services from './pages/Services';
import WebDesign from './pages/services/WebDesign';
import Consulting from './pages/services/Consulting';
<Router>
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<Home />} />
<Route path="about" element={<About />} />
<Route path="services" element={<Services />} >
<Route path="web-design" element={<WebDesign />} />
<Route path="consulting" element={<Consulting />} />
</Route>
<Route path="contact" element={<Contact />} />
<Route path="*" element={<NotFound />} />
</Route>
</Routes>
</Router>
- The
Layoutcomponent wraps all your routes, sharing the navbar and footer. - The
Outletrenders the matched child route. - Nested routes under
serviceswill show inside theServicespage, or you can nest further layouts.
Micro-Project: Add a Nested Services Menu
Inside your Services page, add links to sub-services:
import { Link, Outlet } from 'react-router-dom';
function Services() {
return (
<div>
<h2>Our Services</h2>
<ul>
<li><Link to="web-design">Web Design</Link></li>
<li><Link to="consulting">Consulting</Link></li>
</ul>
<Outlet /> {/* Subpage renders here */}
</div>
);
}
- Now, visiting
/services/web-designshows the Web Design content within the Services page layout.
3. Share Navigation and Structure Across Pages
By using a layout component with Outlet, you avoid repeating navigation and footer code in every page. This makes your React single page application easier to scale and maintain.
4. Understand Route Outlet Concepts
<Outlet />is a placeholder for rendering child routes.- Parent routes can provide shared UI (navigation, wrappers) while nested routes inject their own content.
- This pattern is powerful for both brochure sites and complex apps.
Further Reading
- React Router Layouts & Nested Routes — Guides on creating layouts and nested routes in React Router.
Deploying Your React Brochure Website
After building and testing your React multi-page navigation, the final step is to share your brochure site with the world. Deploying a React app requires a few extra steps to ensure client-side routing works on static hosts like Netlify or Vercel.
This section covers how to build your project, pick a hosting platform, and configure routing for production.
1. Build Your React App for Production
- Run the build command:
npm run build # or yarn build - This creates a
build/folder with optimized static files.
2. Understand Static Hosting Options
- Netlify and Vercel are popular for React app deployment.
- Both support static hosting and make it easy to deploy directly from a Git repository.
- You can also use GitHub Pages, Firebase Hosting, or your own server.
3. Configure Routing for Deployment
React Router uses client-side routing, so you must tell your host to redirect all requests to index.html. Otherwise, deep links like /about will 404 on page reload.
For Netlify:
- Create a
_redirectsfile in yourpublic/folder with this line:/* /index.html 200 - Netlify will route all URLs to your React app.
For Vercel:
- Vercel automatically handles SPA routing for React, but you can add a
vercel.jsonfor advanced rewrites if needed.
4. Troubleshoot Common Deployment Issues
- 404 errors on refresh: Check your host’s routing configuration.
- Environment variables not set: Ensure public URLs and API endpoints are correct in production.
- Static assets not loading: Double-check paths and hosting settings.
Micro-Project: Try Deploying to Netlify
- Push your project to GitHub.
- Create a new site on Netlify, connect your repository, and deploy.
- Visit your live site and test navigation and reloads.
Further Reading
- Vercel Documentation — Covers deploying React apps with static hosting and routing.
- Netlify Docs: Deploy React — Tutorial for deploying React apps to Netlify.
Conclusion and Next Steps
Congratulations! You've now mastered the fundamentals of React Router basics for multi-page navigation in a brochure website. By structuring your app with modular pages, declarative routes, and a robust navigation menu, you've laid the foundation for a professional React single page application.
Here’s what you’ve accomplished:
- Built individual React components for each brochure page
- Set up client-side routing with React Router DOM
- Implemented an accessible, styled navigation menu using NavLink
- Avoided common routing mistakes and followed best practices
- Explored advanced concepts like nested routes and layout components
- Prepared your site for deployment on modern static hosts
Common Questions
- Is React Router suitable for brochure websites?
- Absolutely. React Router makes even small sites more maintainable and user-friendly.
- How do I structure a brochure website in React?
- Organize by pages and components, centralize your routes, and use a layout component for shared structure.
- What’s next after the basics?
- Try dynamic routes, authentication, or server-side rendering for more advanced projects.
Next Steps
- Experiment with route parameters and dynamic content
- Explore advanced React Router features (like loaders, data APIs, or transitions)
- Learn about SEO and accessibility for React SPAs
- Join the React community to stay up-to-date
Further Reading
- React Router Advanced Guides — Offers deeper dives into advanced React Router features.
In the next part, we’ll explore even more advanced navigation patterns and show how to extend your brochure website with interactive features. Happy coding!
About Prateeksha Web Design
Prateeksha Web Design helps businesses turn tutorials like "React Router Basics: Multi-Page Navigation for a Brochure Website" into real-world results with custom websites, performance optimization, and automation. From strategy to implementation, our team supports you at every stage of your digital journey.
Chat with us now Contact us today.
