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

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…

Contents