Building a Common Layout Component
Let's design a layout for the entire app. In this scenario, we'll create a component that aids in navigating through the app's pages and also provides the option to log out (more on authorization in upcoming chapters).
Back to the Project
Now, let's generate a layout.tsx for the dashboard. Within the /dashboard folder, introduce a new file named layout.tsx and insert the following code:
In this code, a few key actions are happening. Let's take a closer look:
- We are bringing in the
<SideNav />component and making it part of our layout. Any components we import here become part of the overall page design; - The
<Layout />component has achildrenprop. This "child" can be either a page or another layout. Specifically, the pages located in/dashboardwill be automatically placed within a<Layout />.
Now, attempt to follow the link http://localhost:3000/dashboard and navigate between the dashboard and the invoices page.


Thanks for your feedback!
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Can you explain how the SideNav component works?
What happens if I add more pages to the /dashboard directory?
How does the children prop get populated in this layout?
Awesome!
Completion rate improved to 2.08
Building a Common Layout Component
Swipe to show menu
Let's design a layout for the entire app. In this scenario, we'll create a component that aids in navigating through the app's pages and also provides the option to log out (more on authorization in upcoming chapters).
Back to the Project
Now, let's generate a layout.tsx for the dashboard. Within the /dashboard folder, introduce a new file named layout.tsx and insert the following code:
In this code, a few key actions are happening. Let's take a closer look:
- We are bringing in the
<SideNav />component and making it part of our layout. Any components we import here become part of the overall page design; - The
<Layout />component has achildrenprop. This "child" can be either a page or another layout. Specifically, the pages located in/dashboardwill be automatically placed within a<Layout />.
Now, attempt to follow the link http://localhost:3000/dashboard and navigate between the dashboard and the invoices page.


Thanks for your feedback!