Questions
25 of 27
1What are client components?
2How to implement client rendering in next js?
3Describe how client components are rendered.
4How to decide what part should be rendered on the server and what on the client?
5Combining client and server components
6How to render a server component in the client component?
7Discuss best approaches with client components.
8Does using 'use client' ensure that the component only renders on the client?
9Explain the full lifecycle of a CSR page in Next.js — from initial HTML delivery to interactive UI.
10What is the difference between useEffect data fetching and React Query / SWR in a CSR context?
11When would you choose CSR over SSR or SSG in a production Next.js app? Give real-world examples.
12How does React's concurrent rendering model affect CSR behaviour in Next.js 13+?
13How do you handle deeply nested Client Components without causing unnecessary re-renders?
14Explain the concept of "client component boundaries" — how do they affect the component tree?
15How would you implement optimistic UI updates in a CSR-heavy Next.js application?
16What are the challenges of using Context API at scale in a CSR and SSR? How do you solve them?
17How does next/dynamic work? How is it different from React's lazy() and Suspense?
18What is the "flash of unstyled/unloaded content" problem in CSR, and how do you prevent it?
19How do you prefetch data for CSR pages in Next.js to reduce perceived latency?
20How do useMemo and useCallback help performance in CSR components? When are they overkill?
21How do you implement skeleton screens or loading states for CSR data fetching?
22Compare SWR vs React Query vs useEffect for client-side data fetching — when do you use each?
23How do you implement infinite scrolling or pagination purely on the client side in Next.js?
24How do you handle race conditions in CSR data fetching with useEffect?
25What is the difference between client-side fetch and server actions in Next.js App Router?
26How do you cancel in-flight API requests when a component unmounts in CSR?
27How would you handle real-time data (WebSockets / SSE) in a Next.js CSR component?
25 / 27

What is the difference between client-side fetch and server actions in Next.js App Router?

Client-side fetch is designed for reading data in the browser with full caching support, while Server Actions are designed for mutating data on the server and are not recommended for data fetching due to lack of caching and serial execution

In the Next.js App Router, client-side fetch and Server Actions serve fundamentally different purposes and operate at different layers of the application. Client-side fetch is a data-fetching mechanism that runs in the browser, ideal for reading data and displaying it to users [citation:8]. Server Actions, marked with the 'use server' directive, are functions that execute exclusively on the server and are primarily designed for mutations—creating, updating, or deleting data [citation:4][citation:9]. While they may appear similar in code structure, their intended use cases, caching behavior, and execution models are completely different.

Core Differences at a Glance
  1. 1

    Primary purpose: Client-side fetch reads data from APIs; Server Actions mutate server-side state (create, update, delete) [citation:4].

  2. 2

    Execution environment: Client-side fetch runs in the browser; Server Actions run exclusively on the server, never in the client bundle [citation:3].

  3. 3

    Caching: Client-side fetch results can be cached by the browser, CDN, or data libraries like SWR; Server Actions have no built-in caching mechanism and process one action at a time [citation:4].

  4. 4

    When to use: Client-side fetch for displaying data to users; Server Actions for handling form submissions, button clicks, or other user-triggered mutations [citation:9].

Client-Side Fetch Example (Reading Data)
Server Action Example (Mutating Data)

A common misconception is that Server Actions can replace client-side fetch for data fetching. The Next.js team explicitly advises against this: "Server Actions are designed for mutations that update server-side state; they are not recommended for data fetching. Accordingly, frameworks implementing Server Actions typically process one action at a time and do not have a way to cache the return value" [citation:4]. This means if you call a Server Action from useEffect to fetch data, you lose caching, deduplication, and parallel request capabilities, and you may encounter performance bottlenecks as actions are processed serially [citation:4][citation:1].

When to Use Each Approach
  1. 1

    Use client-side fetch (or SWR/React Query) for: Displaying data to users, pages that need real-time updates, public content that benefits from caching, and any scenario where you need to read data from an API [citation:8].

  2. 2

    Use Server Actions for: Form submissions that create or update data, button clicks that trigger server-side operations, deleting records, and any mutation where you need direct database access without creating a separate API endpoint [citation:9].

  3. 3

    Use Route Handlers (API routes) for: Building public APIs consumed by third parties, complex endpoints with multiple purposes, and when you need RESTful endpoint semantics [citation:4].

Next.js is evolving toward a more unified model with experimental features like the 'use cache' directive. Unlike Server Actions (for mutations), 'use cache' marks functions as cacheable, automatically deduplicating requests and storing results across requests [citation:10]. This bridges the gap between server-side logic and caching—but importantly, it's separate from Server Actions. The official guidance remains: Server Actions for mutations, client-side fetching (or future cache directives) for reading data [citation:10].