Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn How Next.js Routing Works | Building Pages and Layouts in Next.js
Next.js 14 Mastery for Building Modern Web Apps
course content

Course Content

Next.js 14 Mastery for Building Modern Web Apps

Next.js 14 Mastery for Building Modern Web Apps

1. Introduction to Next.js
2. Setting Up a Next.js Project
3. Building Pages and Layouts in Next.js
4. Deploying a Next.js App and Setting Up a Database
5. Fetching and Displaying Data in Next.js
6. Advanced Next.js Features and Optimizations
7. Implementing Authentication in Next.js

book
How Next.js Routing Works

The Vercel team has chosen a simple approach to routing. They have decided to use folders as routes. This means the more folders you add to your app folder, the more routes you will get. Additionally, if you create a new folder inside of another folder (route), you will get nested routes. To better understand these concepts, we suggest looking at the image below.

We've sorted out the folder structure, but now, let's dive into the files residing within those folders. Next.js accommodates two distinct file types: page.tsx and layout.tsx. The distinction lies in their roles:

  • layout.tsx serves as the file responsible for encapsulating special UI elements shared across multiple pages;
  • Conversely, page.tsx takes charge of the UI specific to the current route, dynamically adapting to URL changes. It embodies the visual representation associated with the unique content and features pertinent to the particular route in focus.

Back to the Project

Let's create a nested route called /dashboard for our application. Follow the steps below to accomplish this:

  1. Create a new dashboard folder inside the app folder;
  2. Inside the newly created dashboard folder, create a new file called page.tsx;
  3. Copy and paste the following content into the page.tsx file.

After completing all the necessary steps, open the following URL http://localhost:3000/dashboard. You should see the created page (Dashboard Page text).

In the following chapter, we will continue our work on the pages. But don't worry, we're still going.

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 1
We're sorry to hear that something went wrong. What happened?
some-alt