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.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!