WhoBuilt

Responding to Reddit on the Next.js App Router

Jul 24, 2023· 12 min· 32K views·Watch on YouTube

Lee Robinson (leerob), a Next.js developer, responds to a Reddit discussion about the Next.js App Router and React Server Components.

Why the component names confuse people

Robinson reads a developer’s concerns about the App Router and explains that Server Components are easy to confuse with server-side rendering. Client Components are also rendered on the server, but add client-side interactivity. He recommends Dan’s diagram for understanding that distinction.

How the App Router changes data and state

In the Pages Router, `getServerSideProps` fetched data on the server and passed it to a page that could use React hooks. With the App Router, a Server Component can fetch data and render HTML on the server, while interactive parts use Client Components. Robinson describes migrating gradually by first passing server-fetched data to a Client Component, then moving more UI to the server.

Adoption can be gradual

Robinson agrees that some App Router models, including Server Actions, were still experimental at the time and advises against adopting them widely. He says the Pages Router remains supported, with new features planned, and developers do not need to move existing apps immediately.

Where Server Components may fit

Robinson says Server Components can suit sites that are mostly presentational content, letting developers use React to produce server-rendered HTML. For interactive applications, he says a client-only approach can still make sense, while using the server can help when an app needs authentication or database access.

React’s server model takes time to learn

Robinson argues that async components and direct data fetching use React primitives more broadly than Pages Router APIs such as `getServerSideProps`. He acknowledges that the shift can be difficult, especially for developers new to React, and says more education and documentation are needed to ease adoption.

Takeaways

  • Use Server Components for UI and data work that can stay on the server; add Client Components where users need interactivity.
  • Treat the Pages Router as a supported option while deciding whether and when to migrate.
  • For gradual adoption, start by fetching data in a Server Component and passing it to an interactive Client Component.
  • Match the rendering model to the product: mostly presentational sites and highly interactive apps may have different needs.

Mentioned in this talk

Search inside this talk

What was claimed 6

  • feature
    React Client Components: Support client interactivity and are also rendered on the server.
    “a Client Component is also rendered on the server”
    YouTube
    Unverified1 source· Talk
  • feature
    App Router: Supports an incremental adoption path from the Pages Router.
    “you can progressively add more UI to your Server Component”
    YouTube
    Unverified1 source· Talk
  • feature
    React Server Components: Can fetch data and produce HTML exclusively on the server.
    “you can also produce HTML and have it run only on the server”
    YouTube
    Unverified1 source· Talk
  • feature
    Server Actions: Were still in alpha or experimental and were not recommended for broad use.
    “For now, I wouldn’t recommend using them widely”
    YouTube
    Unverified1 source· Talk
  • feature
    Pages Router: Continues to be supported, with new features added.
    “the Pages Router continues to exist and will continue to be supported, with even new features added”
    YouTube
    Unverified1 source· Talk
  • feature
    Remix: Provides loaders for server-side data fetching.
    “The concept of a loader in Remix, for example, is similar to getServerSideProps”
    YouTube
    Unverified1 source· Talk

Related talks