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.

File-based routing and navigation

File-based routing and navigation

Now that we have our clean Next.js project set up, let's explore one of its most powerful features – file-based routing. In this session, I am going to show you one of the most powerful features of Next.js – its file-system-based router. By the end of this lecture, you will understand how Next.js automatically handles routing based on the file system, how to create multiple pages using folders and files, and how to navigate between pages using the built-in link component. In plain React, we have to set up routing ourselves, installing React Router DOM, wrapping the app in Browser Router, and defining routes and route for each page. Next.js makes this effortless. Routing is automatic, based on the folder structure inside your app slash directory. Create a file and it instantly becomes a route. This is one of the first ways Next.js saves us time and reduces boilerplate. Let's see how it works. Inside your src slash app folder, we already have one file called page.js. This corresponds to…

Contents