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
Published a year ago
Updated a year ago

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.

egghead
egghead
~ 17 minutes ago

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

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

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!

Markdown supported.
Become a member to join the discussionEnroll Today