When you create a new project with the latest create-next-app
, it uses the recently released App Router feature by default. Hence, your project contains the app
directory instead of pages
.
$ npx create-next-app@latest
✔ What is your project named? … nextjs-project
✔ Would you like to use TypeScript? … Yes
✔ Would you like to use ESLint? … Yes
✔ Would you like to use Tailwind CSS? … No
✔ Would you like to use `src/` directory? … No
✔ Would you like to use App Router? (recommended) … Yes
✔ Would you like to customize the default import alias (@/*)? … No
$ tree -d -L 1 nextjs-project
nextjs-project
├── app
├── node_modules
└── public
This is the default project structure moving forward, and you can find all relevant documentation and examples under the "Using App Router" section of Next.js docs.
https://nextjs.org/docs/app/building-your-application/routing
However, if you prefer not to use the App Router, you should answer "No" to the "Use App Router (recommended)?" question. In this case your project will contain the pages
directory.
$ npx create-next-app@latest
✔ What is your project named? … nextjs-project
✔ Would you like to use TypeScript? … Yes
✔ Would you like to use ESLint? … Yes
✔ Would you like to use Tailwind CSS? … No
✔ Would you like to use `src/` directory? … No
✔ Would you like to use App Router? (recommended) … No
✔ Would you like to customize the default import alias (@/*)? … No
$ tree -d -L 1 nextjs-project
nextjs-project
├── node_modules
├── pages
├── public
└── styles
You can find legacy Pages Router documentation under the "Using Pages Router" section of Next.js docs.
https://nextjs.org/docs/pages/building-your-application/routing