In Next.js

  • App router
    • A newer router that allows you to use react’s latest features like Server components and Streaming
    • Preferred in the official docs, new and more recommended
    • Uses React Server Components by default
  • Page router
    • Original Next.js router
FeatureApp RouterPage Router
File-based routingUses nested folders to define routesFiles directly represent routes
ComponentsServer Components by defaultClient Components by default
Data fetchingfetch function for data fetchinggetServerSideProps, getStaticProps, getInitialProps
LayoutsLayouts can be nested and dynamicLayouts are static
Dynamic routesSupported, but syntax differsSupported
Client-side navigationSupported with router.pushSupported with Link component
PriorityTakes precedence over Page RouterFallback if no matching route in App Router

Non-Next.js

  • React router
    • The standard, most popular routing library for client-side React applications
    • It’s used in React apps built with tools like Create React App or Vite (i.e., not Next.js)
    • Handles routing entirely in the user’s browser (client-side). When you click a link, React Router intercepts it, prevents the browser from reloading, and just swaps out the React components to make it look like you changed pages
    • It’s all about CSR!
      • server sends one minimal HTML file and a big JavaScript bundle. The user’s browser then runs the JavaScript to render the page and handle all navigation

Sources