From the course: Master Next.js: Elaborate Hands-On Web Development, React Basics, Advanced Next.js, and Deployment
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
How pages work in Next.js
From the course: Master Next.js: Elaborate Hands-On Web Development, React Basics, Advanced Next.js, and Deployment
How pages work in Next.js
Okay, so we got this homepage going and before we add more pages, just recall that this index.js had to be moved into the pages directory, which means that basically this homepage that we're seeing is a React component exported from a file from the index file specifically in the pages directory. So that means that pages are associated with a route based on their file name. There's a route on the file name. Right now it's index, but index defaults with just a slash. It's just an open slash because it's the index. There's nothing going to be here. But if we were to create another page, another file, and called it hot dog or popsicle, then in order to route to that page, to that component, which would happen automatically, we could just type in slash hot dog slash popsicle. All right. So we already have the index. Let's actually see this in real life. We're not going to make a hot dog pitch because it's not food app But let's make a first post because we're going to be making a blog…
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)
Introduction and quick note about the upcoming final project2m 21s
-
(Locked)
How to start a Next.js template locally6m 12s
-
(Locked)
Next.js template file structure overview4m 30s
-
(Locked)
How pages work in Next.js3m 16s
-
(Locked)
Prefetching and codesplitting with Link and CSN – client-side navigation in Next.js9m 9s
-
(Locked)
-
-
-
-