Questions
33 of 33
1Explain server-side rendering (SSR) in Next.js.
2List the benefits of Server-Side Rendering in Next.js.
3What are server components?
4How to use server components in next js?
5What is the React Server Component Payload (RSC)?
6Describe how server components are rendered.
7Describe server rendering strategies
8How can you keep Server-only Code out of the Client Environment
9What are the issues of using context provider at the root of the application?
10List dynamic functions available to server components.
11List all Dynamic APIs.
12How do we opt for Static Rendering, Dynamic Rendering and Streaming?
13Explain the difference between SSR, SSG, ISR, and CSR in Next.js. When would you choose each?
14How does getServerSideProps work internally? What is its execution context?
15What are the performance trade-offs of SSR vs SSG in a high-traffic production app?
16How does Next.js handle hydration? What is a hydration mismatch, and how do you debug it?
17What happens when getServerSideProps throws an error? How do you handle it gracefully?
18How would you architect a Next.js app that needs both personalised (SSR) and cacheable (SSG) pages at scale?
19Explain the App Router vs Pages Router SSR model differences. How does React Server Components change the SSR paradigm?
20How do React Server Components (RSC) differ from traditional SSR? Can they be used together?
21How does streaming SSR work in Next.js 13+? What role does Suspense play?
22How would you implement partial hydration or Islands Architecture in Next.js?
23Explain how Next.js handles data fetching waterfall problems in SSR and how you'd mitigate them.
24How would you implement partial hydration or Islands Architecture in Next.js?
25How do you implement caching strategies for SSR responses in Next.js? (CDN, Cache-Control, stale-while-revalidate)
26How would you reduce TTFB (Time to First Byte) in an SSR-heavy Next.js app?
27What's the difference between fetch caching in the App Router vs traditional getServerSideProps?
28How do you avoid redundant database/API calls across multiple server components on the same page?
29How do you securely handle authentication in SSR? What are the risks of passing tokens via cookies vs headers?
30How do you prevent sensitive server-side data from leaking to the client bundle?
31How would you implement role-based rendering on the server without exposing protected routes to the client?
32How do you debug SSR-only issues that don't appear in local development?
33How can we control dynamic rendering behaviour in next js?
33 / 33

How can we control dynamic rendering behaviour in next js?

Control dynamic rendering in Next.js using the dynamic route segment config ('auto', 'force-dynamic', 'error', 'force-static'), dynamicParams, and granular fetch caching options, shifting from page-level decisions to component-level control [citation:2][citation:5].

Next.js provides multiple ways to control rendering behavior, ranging from coarse-grained route-level configuration to fine-grained per-fetch control. The primary mechanism is the dynamic route segment config exported from layout.tsx, page.tsx, or route.ts files, which allows you to override the default rendering strategy for that segment [citation:2][citation:4].

Route Segment Config Options

The dynamic configuration offers four distinct modes. 'auto' (the default) caches as much as possible while still allowing components to opt into dynamic behavior. 'force-dynamic' forces dynamic rendering for each request, equivalent to setting { cache: 'no-store' } on all fetches and is useful for user-specific dashboards or real-time data [citation:2][citation:9]. 'error' enforces static rendering and throws an error if any dynamic APIs are used, helping maintain static builds. 'force-static' also forces static rendering but makes dynamic APIs return empty values, useful for pages that should be static but are impacted by dynamic functions like cookies() [citation:2][citation:7].

Practical Examples

For dynamic routes, the dynamicParams configuration controls what happens when a visitor requests a path not generated by generateStaticParams. When true (default), Next.js generates the page on-demand (streaming server rendering). When false, non-generated paths return a 404. This replaces the fallback option from the Pages Router [citation:2][citation:7].

dynamicParams Configuration

Rather than forcing entire routes to be static or dynamic, Next.js recommends granular caching at the fetch request level. You can control individual data fetches using the cache and next.revalidate options, allowing static and dynamic content to coexist within the same page [citation:5].

Granular fetch Configuration

Next.js automatically opts pages into dynamic rendering when they use dynamic functions like cookies(), headers(), or searchParams, or when they contain uncached fetches. This automatic detection allows you to rely on the default 'auto' setting while letting the framework make intelligent rendering decisions based on your code [citation:9][citation:10].

Best Practices Summary
  1. 1

    Use 'auto' as default: Let Next.js automatically determine the optimal rendering strategy based on your data fetching patterns.

  2. 2

    Prefer granular fetch caching: Use cache: 'force-cache' for static data, cache: 'no-store' for dynamic data, and next.revalidate for ISR.

  3. 3

    Use dynamic: 'force-dynamic' for user-specific pages: Dashboards, profile pages, and real-time data that change per request.

  4. 4

    Use dynamic: 'error' to enforce static builds: Ensure pages remain static and fail the build if dynamic APIs are accidentally introduced.

  5. 5

    Avoid overusing force-dynamic: The Next.js team recommends granular fetch caching over forcing entire routes to be dynamic, as it enables future optimizations like partial static subtrees [citation:1][citation:5].