Next.js
/Intermediate
Pages Router vs App Router
Definition
The architectural differences between the legacy Next.js routing system (`pages/`) and the modern routing system (`app/`).
Explain Like I'm New
Pages router: Fetched data at the page level using weird Next.js specific functions like `getServerSideProps`. App router: Uses standard async/await directly inside React components, and leverages React Server Components.
Real World Example
Migrating an old Next.js 12 blog to Next.js 14, changing `export async function getStaticProps` into standard `const data = await fetch()` inside the component.
Common Use Cases
- •Legacy code migration
- •Understanding Next.js history
Interactive Example
Loading Code Playground...
Interview Questions
basic
- Which router is the recommended, modern way to build Next.js applications?
intermediate
- Can you use the `pages` and `app` router in the same project?