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

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

Implement partial hydration in Next.js using client component boundaries, dynamic imports with SSR, and third-party libraries like next-lazy-hydrate to defer hydration of non-critical UI islands

Partial hydration and Islands Architecture represent a shift from monolithic client-side applications to a model where most of the page is static HTML, with only isolated interactive 'islands' that hydrate independently. In Next.js, you can implement this pattern through a combination of built-in features: React Server Components for static content, Client Components with strategic 'use client' boundaries, dynamic imports with SSR disabled, and libraries that provide granular control over when and how components hydrate. The goal is to reduce JavaScript execution during page load, improving metrics like Time to Interactive (TTI) and First Input Delay (FID).

Understanding Islands Architecture
  1. 1

    Core concept: A page is primarily server-rendered static HTML (the 'sea'), with isolated interactive components ('islands') that hydrate independently.

  2. 2

    Benefits: Reduces JavaScript payload, eliminates unnecessary hydration of static content, improves performance on low-end devices, and maintains SEO benefits of server rendering.

  3. 3

    Contrast with traditional SSR: Standard Next.js Pages Router hydrates the entire application at once, blocking interactivity until all JavaScript loads and executes.

  4. 4

    Islands can be loaded based on triggers: viewport visibility, user interaction, idle time, or media queries.

Method 1: Using Next.js Dynamic Imports with SSR Control

Next.js App Router's React Server Components (RSC) provide a natural foundation for Islands Architecture. By default, all components are Server Components that render on the server and send zero JavaScript to the client. Only components 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 (buttons, forms, carousels) become client components. The key insight is that Server Components can render Client Components, creating clear boundaries where hydration occurs.

Method 2: Server Components with Client Islands

For more sophisticated partial hydration scenarios, community libraries provide additional control. Libraries like next-lazy-hydrate allow you to defer component hydration based on triggers like viewport visibility, user interaction (hover, click), or idle time. These libraries work by skipping the initial hydration of components and loading their JavaScript only when needed. This can dramatically improve TTI (Time to Interactive) on pages with many interactive elements that don't need to be interactive immediately. The library react-hydration-on-demand provides similar functionality with a simple API.

Method 3: Using next-lazy-hydrate

For complete control, you can implement your own viewport-based hydration using the Intersection Observer API. This approach lets you detect when a component becomes visible and load its JavaScript only at that moment. Combined with React's lazy loading and Suspense, this creates a powerful pattern where off-screen interactive components don't block the initial page load. This is particularly valuable for long pages with interactive elements below the fold.

Method 4: Custom Intersection Observer Hydration
Hydration Triggers Comparison
  1. 1

    Immediate (client:load): Hydrates as soon as page loads. Use for critical UI above the fold.

  2. 2

    Idle (client:idle): Hydrates after browser idle time. Use for non-critical enhancements.

  3. 3

    Visible (client:visible): Hydrates when component enters viewport. Perfect for below-the-fold content.

  4. 4

    Media query (client:media): Hydrates only when media condition matches. Great for mobile-only components.

  5. 5

    Interaction (hover/click): Hydrates on first user interaction. Good for tooltips, dropdowns.

Next.js is evolving toward Partial Prerendering (PPR), which conceptually aligns with Islands Architecture but works differently. PPR prerenders a static shell at build time while leaving dynamic 'holes' that stream at request time. Islands Architecture traditionally loads static HTML first, then hydrates client-side. PPR combines both: static shell from CDN, dynamic content streams from server. In Next.js 15+, you can enable PPR experimentally to get a similar outcome: most of the page is static, interactive islands are dynamic and can access server-side data like cookies and headers.

Island State Management with Nano Stores
Performance Metrics and Benefits
  1. 1

    Time to Interactive (TTI): Can improve by 50-80% by deferring non-critical hydration.

  2. 2

    First Input Delay (FID): Reduces because main thread is free during initial page load.

  3. 3

    JavaScript bundle size: Up to 90% reduction in initial JS for content-heavy pages.

  4. 4

    Lighthouse scores: Islands architecture typically yields scores above 90 on content sites.

Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.