From the course: Next.js 14 from Scratch: Build a Real-World Project Using Next.js 14 and MongoDB
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
File-based routing - Next.js Tutorial
From the course: Next.js 14 from Scratch: Build a Real-World Project Using Next.js 14 and MongoDB
File-based routing
All right, so now we're going to get into file-based routing. And this is the documentation here for Next.js routing if you want to check that out. And you don't have to, but you can use it as a supplement. So basically, we're using the app folder structure. There's two ways to do things. There's the older pages folder that you can use, or the newer app folder, which is what we're using. So app is basically the root for our routes. And then we can create subfolders that we want to pertain to specific routes. So let's say I want to have a page or component load when I go to slash properties. Right now, obviously, I get a 404 because that doesn't exist. But I don't have to install React Router. I don't have to write out my routes like you would with a single page application. All I have to do is go into my app folder and create a new folder called Properties, or whatever I want that route to be. And then inside that folder, I'm going to create a file. And I'm going to name it page.jsx…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
(Locked)
New project and folder structure6m 13s
-
(Locked)
Layout, homepage, and metadata10m 47s
-
(Locked)
File-based routing7m 16s
-
(Locked)
Server vs. client components and router hooks9m 44s
-
(Locked)
Start on the navbar10m 3s
-
(Locked)
Navbar links, drop-downs, and React icons12m 28s
-
(Locked)
Active links and conditional rendering11m 48s
-
(Locked)
Homepage components15m 45s
-
(Locked)
Properties page7m 26s
-
(Locked)
Property card dynamic data14m 41s
-
(Locked)
Home property listings7m 42s
-
(Locked)
Custom not found and loading pages5m 58s
-
(Locked)
-
-
-
-
-
-
-
-