From the course: Master React 19 and Next.js 16 with Hands-On Projects and Real-World Applications

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Introduction to routing in React

Introduction to routing in React

In this session, you will learn the fundamentals of routing in React using the popular React Router DOM library. We'll cover setting up routes, navigating between them, and styling active links. By the end, you'll be able to create dynamic and multi-page React applications with ease. Let's begin with a simple React component. This is our starting point, before introducing routing. In a typical React single-page application, there's only one HTML file, usually index.html. Without routing, all content exists on a single page, so navigating between different sections or pages is cumbersome or impossible. The user sees one giant page, and the app doesn't behave like a traditional website. Routing solves this by mapping each URL to a specific React component. For example, using React Router, we can define a root for forward slash that renders the Home component and another for slash about that renders the About component. This way, the user can navigate between views smoothly, without a…

Contents