Panji Asniar

Panji Asniar

App Router vs Pages Router in Next.js

Next.js offers two routing systems: the traditional Pages Router and the newer App Router introduced in Next.js 13.

Pages Router

The Pages Router uses the pages/ directory and has been the standard approach since Next.js was created.

  • File-based routing with pages/ directory
  • Uses getStaticProps and getServerSideProps for data fetching
  • Simpler mental model and mature ecosystem
  • Great for most applications

App Router

The App Router uses the app/ directory and brings React Server Components to Next.js.

  • File-based routing with app/ directory
  • Built-in support for React Server Components
  • New data fetching patterns with async components
  • Nested layouts and improved loading states

Which One Should You Use?

For new projects, the App Router is recommended as it represents the future of Next.js. However, the Pages Router remains fully supported and is still a great choice, especially for simpler applications or when you need maximum stability.

You can even use both in the same project during migration!