Next.js App Router
Server vs client components, streaming, route handlers, server actions, ISR vs SSR vs static. Knowing what runs where is the whole game.
The mental model
The App Router's entire premise is one question asked of every line of code: does this run on the server, on the client, or both? Get that boundary right and everything else follows; get it fuzzy and you ship secrets to the browser, waterfall your data fetches, or hydrate megabytes of JavaScript you never needed.
The mental model that makes it click: **the App Router is a server-first framework where "client-side React" is an opt-in island.** By default every component is a **Server Component** — it runs once on the server during the request, can talk directly to your database, renders to HTML, and ships *zero JavaScript* to the browser. When a component genuinely needs interactivity — state, effects, event handlers, browser APIs — you mark it 'use client', and that component (and its imported children) becomes a hydrated island that ships JS and runs in the browser.
The analogy: think of a page as a **printed newspaper with a few embedded gadgets**. Most of the page is ink on paper — rendered once, static, weightless (Server Components producing HTML). A few spots are little battery-powered widgets glued onto the paper — a like button, a search box, a live ticker (Client Components). The newspaper is mostly paper; the widgets are the exception you pay for. The failure mode of developers coming from the Pages Router or a pure-SPA background is treating the whole page as one big widget — 'use client' at the top of the tree, so the entire page becomes a client bundle and the server-first advantage evaporates.
Why this exists: shipping less JavaScript is the highest-leverage performance lever on the web, and doing data fetching next to the database (no client round-trip, no API layer just to read) removes a whole class of waterfalls and over-fetching. The cost is that you must always know what runs where — which is why interviewers say knowing that boundary "is the whole game."
- Deep dive
- Internal architecture
- Real-world use cases
- Best practices
- Common mistakes
- Performance
- Security
- Production troubleshooting
- Advantages & disadvantages
- Alternatives
- Interview expectations
- Interview questions
- Facts to remember
- Cheat sheet
- Quick revision