1. 7
    Initialize the App Router in a Next.js Project
    1m 38s

Initialize the App Router in a Next.js Project

Ben Patton
InstructorBen Patton
Share this video with your friends

Social Share Links

Send Tweet

Add the app router to your project by adding a new folder in the src directory called app. To test create a new route (folder) with a page.tsx file.

Instructor: [0:00] Our first step toward using the app router is to simply add the app directory. If we come into source, click add New Folder, add app. Let's add a new file. Let's call this dashboard...Now in pages, you would call this dashboard.tsx, but in the app router, we have to give it the /page.tsx.

[0:26] Then here, we can say, export default function DashboardPage(), and we want to return some HTML. We'll return a <div> with an <h1> of Hello Dashboard page. If we save this, now if we start our server, now if we go to the dashboard page, we see that we get Hello from the dashboard page.

[1:08] Obviously, we don't have any of our layouts being applied. That's because this is a different router. We'll work on those in the coming lessons. In review, in this lesson, we saw how to add the app router to our application by adding the app folder and then giving it a page name.

[1:27] We gave it the dashboard name and then you have to add the page.tsx for the page itself. Now, we have the app router in our application.