Partial Hydration — rendering optimisation: instead of loading + hydrating the entire React app, hydrate only components that need client-side interactivity. Zero JS for static read-only blocks. Implementations: Islands (Astro), RSC (Next.js), Resumability (Qwik), Progressive Hydration (Marko).
Below: details, example, related terms, FAQ.
Free online tool — HTTP header checker: instant results, no signup.
// Astro — client directives
<StaticHero /> {/* zero JS */}
<LikeButton client:load /> {/* hydrate immediately */}
<Comments client:visible /> {/* hydrate when scrolled to */}
<CartModal client:media="(max-width: 768px)" /> {/* mobile only */}Partial hydration is an advanced rendering optimization technique used in modern web development to enhance performance and reduce the amount of JavaScript that needs to be executed on the client side. Instead of fully hydrating the entire React application on the client, partial hydration focuses on selectively hydrating only those components that require client-side interactivity. This approach is particularly beneficial for applications with a mix of static content and dynamic components, as it allows developers to minimize the JavaScript footprint and improve load times.
In a typical hydration process, the server sends fully rendered HTML to the client, which then 'hydrates' the components by attaching event listeners and enabling interactivity. With partial hydration, developers can identify which components are interactive and only hydrate those, leaving static blocks untouched. This leads to faster initial rendering and a better user experience, especially on slower networks or devices.
Several frameworks have adopted this concept, employing different implementations to achieve partial hydration:
To implement partial hydration in your project, you can leverage specific frameworks and libraries that support this technique. Below are examples of how to set up partial hydration using popular tools like Astro and Next.js.
Using Astro:
import { defineConfig } from 'astro/config'; import { partialHydration } from 'astro-partial-hydration'; export default defineConfig({ integrations: [partialHydration()], }); In your Astro component, you can define interactive elements as follows:
<!-- Component.astro --> <script type="module" client:only="interactive"> import InteractiveComponent from '../components/InteractiveComponent.astro'; export default InteractiveComponent;</script> <div>Static Content Here</div> Using Next.js with React Server Components:
import { useEffect } from 'react'; const MyComponent = async () => { return <div>Server Rendered Content</div>; }; export default function Page() { return <MyComponent />; } In this setup, ensure that only the components requiring client-side rendering are marked for hydration. This selective approach significantly optimizes performance by reducing the amount of JavaScript loaded and executed.
Partial hydration offers several benefits, but also comes with its own set of challenges that developers must consider when implementing it in their applications.
Overall, while partial hydration can greatly enhance performance and user experience, it is essential to weigh these benefits against the potential challenges to determine if it is the right approach for your project.
You download 200 KB React + 50 KB your code, execute it all, re-render server HTML. TBT huge on mobile.
Instead of hydration — serialise closures in HTML attributes, lazy-load on event. Zero initial JS for complex apps.
Lighthouse Speed Index + TBT. Partial hydration cuts from 3s → 0.3s on a typical blog.
Free plan — 10 monitors, checks every 5 min, no card required. Upgrade for 1-minute interval and multi-region monitoring.