🎓 A1Learner
🔍
0 of 50 lessons completed

Next.js App Router vs Pages Router

Next.js has two routers. The App Router is the current default, and the Pages Router is the old way.

This app has an app folder, not a pages folder

The check reads the project folders. The app folder exists, and the pages folder does not.

node -e 'const fs=require("fs"); console.log("app folder exists:", fs.existsSync("app")); console.log("pages folder exists:", fs.existsSync("pages")); console.log("Default router: App Router");'

The app folder holds the pages

The app folder holds four files. The page file is page.tsx, and the wrapper file is layout.tsx.

ls app

Example

const router = "App Router";
const folder = "app";
console.log("Folder:", folder);
console.log("Router:", router);
console.log("Old tutorials use the pages folder.");
console.log("This course uses the app folder.");

Key points

  • App Router: the current router, built on the app folder
  • Pages Router: the old router, built on the pages folder
  • A folder named app means the App Router. A folder named pages means the Pages Router.
  • New apps use the App Router. It is the default in the setup tool.
  • Old tutorials show the pages folder. Their page files still work, but they teach the old router.
  • This course uses the App Router only.

In this example, the folder and the router are named together. The app folder means the App Router, and the pages folder means the Pages Router. Old tutorials show the pages folder, so a reader who follows one is learning the old router. This course uses the app folder, so every page in this course follows the current router.

Note

Do not mix the two routers in one app. Pick the app folder and stay with it.

Try it Yourself

Edit the code, then press Run.

Running is simulated · TypeScript Playground

Exercise

Which folder means the App Router?