Learn Programming, Tech & Coding · Free Online Tools

IT Question Answer
Back to Next.js

Next.js App Router vs Pages Router

Next.js2,890 viewsBy Muhammad Fareed
nextjsreactroutingapp-router

Next.js App Router vs Pages Router

Compare Next.js App Router and Pages Router to understand which to use for your project.

Pages Router (Traditional)

pages/
  index.tsx
  about.tsx
  blog/
    [slug].tsx

App Router (Modern)

app/
  page.tsx
  about/
    page.tsx
  blog/
    [slug]/
      page.tsx

Key Differences

1. File Structure

  • Pages Router: One file per route
  • App Router: Folder-based routing with page.tsx

2. Server Components

  • Pages Router: Client-side by default
  • App Router: Server components by default

3. Data Fetching

  • Pages Router: getServerSideProps, getStaticProps
  • App Router: Async components, fetch with caching

Which Should You Use?

Use App Router for:

  • New projects
  • Better performance
  • Modern React features

Use Pages Router for:

  • Existing projects
  • Specific requirements
  • Team familiarity