Questions
24 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?
24 / 33

How would you implement partial hydration or Islands Architecture in Next.js?

Implement Islands Architecture in Next.js using React Server Components as the static 'sea', Client Components as interactive 'islands', dynamic imports with SSR control, and hydration trigger libraries like next-lazy-hydrate for deferred hydration

Islands Architecture transforms the traditional monolithic hydration model by treating most of a page as static HTML (the 'sea') with isolated interactive components ('islands') that hydrate independently [citation:5]. In Next.js, this is achievable through a combination of React Server Components for static content, strategic 'use client' boundaries for interactive pieces, dynamic imports to control JavaScript loading, and community libraries that provide granular control over when and how components hydrate [citation:8][citation:9].

Core Concepts of Islands in Next.js
  1. 1

    Default static rendering: With the App Router, components are Server Components by default, rendering on the server and sending zero JavaScript to the client—perfect for the static 'sea' [citation:2].

  2. 2

    Explicit interactivity boundaries: Adding 'use client' at the top of a file creates an interactive island that hydrates on the client, but only that component and its children become JavaScript bundles [citation:9].

  3. 3

    Selective hydration: Islands can be configured to hydrate based on triggers like viewport visibility, user interaction, or browser idle time, reducing initial JavaScript execution [citation:6][citation:8].

  4. 4

    Independent operation: Each island operates in isolation, which requires thoughtful state management solutions like Nano Stores for cross-island communication [citation:5].

Next.js App Router's React Server Components (RSC) provide the natural foundation for Islands Architecture. By default, all components are Server Components that render on the server and send zero JavaScript to the client [citation:2]. Only components explicitly marked with 'use client' become interactive islands that hydrate. This means you can build pages where 90% of the UI is static HTML, and only the truly interactive pieces become client components. The key insight is that Server Components can render Client Components, creating clear boundaries where hydration occurs [citation:9].

Method 1: Server Components with Client Islands

For components that are below the fold or non-critical, you can use Next.js dynamic imports with SSR disabled. This ensures the component's JavaScript only loads when needed—for example, when the user scrolls to it or after the page becomes interactive [citation:7][citation:8]. This technique dramatically reduces initial bundle size and improves Time to Interactive (TTI).

Method 2: Dynamic Imports with SSR Control

For granular control over when islands hydrate, you can use the Intersection Observer API to detect when a component becomes visible and load its JavaScript only at that moment. This is particularly valuable for long pages with interactive elements below the fold [citation:6][citation:8]. The library 'react-hydration-on-demand' implements this pattern, allowing components to hydrate only when they enter the viewport [citation:8].

Method 3: Custom Viewport Hydration Hook

The community library 'next-lazy-hydrate' provides a clean API for deferring component hydration based on multiple triggers like viewport visibility, hover, or browser idle time [citation:8]. This library builds on concepts from 'react-hydration-on-demand' and integrates seamlessly with Next.js. It allows you to control exactly when each island's JavaScript loads and executes, giving you fine-grained performance optimization [citation:8].

Method 4: Using next-lazy-hydrate

One challenge with Islands Architecture is that islands are isolated—they can't share state through React Context because they're separate component trees [citation:5]. The solution is to use a lightweight store like Nano Stores, which works across framework boundaries and is extremely small (less than 1KB). Islands can import the same store and stay synchronized without needing a shared React context provider [citation:5].

Method 5: Nano Stores for Island Communication
Hydration Triggers Comparison
  1. 1

    client:load (immediate): Hydrates as soon as page loads. Use for critical UI above the fold like navigation and search bars [citation:5].

  2. 2

    client:idle (idle time): Hydrates after browser idle time. Perfect for non-critical enhancements like chat widgets or notification panels [citation:5].

  3. 3

    client:visible (viewport): Hydrates when component enters viewport. Ideal for below-the-fold content like comments sections or footers [citation:5][citation:8].

  4. 4

    client:media (media query): Hydrates only when media condition matches. Great for mobile-only components like hamburger menus [citation:5].

  5. 5

    client:only (no SSR): Skips server rendering entirely, useful for components that depend on browser APIs [citation:5].

Implementing Islands Architecture in Next.js can dramatically improve core web vitals. Traditional hydration forces the browser to parse and execute JavaScript for the entire page, even for static content [citation:8][citation:9]. With partial hydration, initial JavaScript payloads can be reduced by 50-90%, leading to faster Time to Interactive (TTI) and better First Input Delay (FID) [citation:7][citation:8]. For content-heavy sites like blogs, documentation, or e-commerce product pages, this approach often yields Lighthouse scores above 90 without compromising functionality [citation:5].

Decision Framework: When to Use Each Approach
  1. 1

    Server Components (default): Use for all static content that doesn't need interactivity—article text, product descriptions, images, headers [citation:2][citation:9].

  2. 2

    Client Components with 'use client': Use for interactive elements that must be interactive on load—navigation menus, search bars, forms [citation:9].

  3. 3

    Dynamic imports with ssr:false: Use for heavy interactive components below the fold—carousels, maps, comment sections [citation:7].

  4. 4

    next-lazy-hydrate with triggers: Use for components that can wait for specific conditions—footer widgets, hover tooltips, mobile-only menus [citation:8].

  5. 5

    Nano Stores: Use when multiple islands need to share state—cart counters, user preferences [citation:5].