Next.js App Router vs Pages Router
N نکست.جی‌اس

Next.js App Router vs Pages Router

Know when to use each, how routing differs, and what interviewers ask in 2026.

BugCast Admin··۸ دقیقه مطالعه

Two Routing Systems

Pages Router (legacy): pages/ directory, file-based routing, getServerSideProps, getStaticProps.

App Router (modern): app/ directory, React Server Components, layouts, nested routing.

Key Differences

FeaturePages RouterApp Router
Directorypages/app/
Default componentsClientServer
Data fetchinggetServerSidePropsasync Server Components
Layouts_app.js manuallayout.tsx nested
Loading statesManualloading.tsx

Interview Questions

Q: Why did Next.js introduce the App Router?

  • Native React Server Components
  • Better streaming and Suspense
  • Colocation of loading, error, and layout files
  • Improved data fetching patterns

Q: Can you use both in one project?

Yes — app/ and pages/ can coexist during migration. App Router takes precedence for conflicting routes.

Q: When would you still use Pages Router?

Legacy projects, simpler client-only apps, or when team isn't ready for RSC mental model.

Migration Tip

Start new features in app/, migrate high-traffic pages first, keep API routes in either location.

#app-router#routing#interview

مطالب مرتبط