Hydration, Islands, Streaming, Resumability… Oh My!

Rate this content
Bookmark

Our ecosystem can be overwhelming! First, we had the rise of SSR and SSG—and each had its own gigantic pile of frameworks and tools. Then partial hydration enabled us to hydrate only some of our components on the client, which we've seen in React Server Components. 


But what about islands? Do they relate at all to Streaming SSR? Moreover, what is resumability, and why do I keep hearing about it? […] Oh, did anyone say rendering on the Edge?


Well… There are many approaches out there, and all of them argue that their philosophy is best. In this session, we’ll go over these architecture/rendering patterns, to help shed some light on how some are implemented and the concepts behind them.

Matheus Albuquerque
Matheus Albuquerque
26 min
20 Oct, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Today's Talk introduces the concepts of hydration and off islands, explores the benefits of islands for enhancing server-side rendered HTML with client-side JavaScript, discusses the lazy approach of re-zoomability and its advantages over traditional hydration, highlights the use of resumability and concurrent React for improved rendering performance, examines the features and concerns of React server components, touches on the co-location of client and server code, and explores future trends in rendering and navigation. The Talk also reflects on past ideas and emphasizes the importance of identifying core metrics for performance optimization.

1. Introduction to Hydration and Off Islands

Short description:

Today we'll discuss hydration, its challenges and issues, and the concept of off islands introduced by Jason Miller in 2020.

So, hello, London. It's just great to be here at this amazing conference again. And, yeah, I'm Mathias Apkarky, and today we're here to discuss about hydration, islands, streaming, resumability, and, wow, we should probably start, right?

So this is what we wanna cover today. We'll talk a little bit about the past and the future of things. And then we'll go to islands, resumability. We'll also talk about streaming SSR and how it combines with selective hydration. We should talk about React server components, right? And then we'll draft some closing thoughts on top of things.

And let's just start with hydration because, yeah, we wanna cover that. So if you're not familiar, I love this definition by Mishko, that hydration is the process of attaching behavior to declarative content to make it interactive. And hydration comes with a few challenges. So first, and obviously you have to associate the DOM elements with their corresponding event handlers. But also as a user, for example, triggers one of these handlers, you want to update the state of your app. And not only that, but once the state is updated, your framework needs to recreate the DOM hierarchy and everything. So hydration comes with challenges and hydration also comes with issues. And that's one of the most common ones. It's called the uncanny valley. And it happens exactly, so you got your initial request, you got your HTML and then you have your view painted, but then you have to wait for to arrive, to be executed, parsed, and everything. So the uncanny valley is this moment where everything is painted, but you don't have interaction, which is bad. And if we break down, it all starts, for example, when we get the HTML. And that's mostly fast, of course, but then you have to download JavaScript, and that can be slow depending on the network conditions of your users, as you probably know. Also, you have to parse and execute JavaScript. And that can be also slow depending on the capabilities of devices of your users. And also on the amount of JavaScript you're sending over the wire. And last but not least, your framework also has to recover, state, and bind all the listeners. And that can be slow depending on, for example, the amount of done nodes you need to go through. And also the amount of references that you need to rebind to those listeners. We could be here the whole day talking about the challenges and the issues with hydration, and you also have a lot of interesting posts out there. But the point is, throughout the years, people were trying to think of creative ways to fix or address, at least some part of this problems. And it was in 2020 that we started to listen a lot about the term off islands. And we got this name from this post by Jason Miller, the creator of React and also the creator of other amazing open source stuff.

2. Introduction to Islands and Their Benefits

Short description:

Islands are a way to selectively enhance server-side rendered HTML with client-side JavaScript, providing small focus chunks of interactivity. They allow for more specificity in enhancing the page and can be delivered and hydrated independently. There are various tools and frameworks available for building islands, such as Astro, Quake, Markle, Preact, Solid, and Svelte. Markle and Astro offer interesting combinations of features, including streaming, automatic partial hydration, and customizable loading strategies. Islands help reduce JavaScript code shipped to the client, resulting in faster page loads and improved metrics like TTI.

But if we dig a bit back in time, we find posts like this. So this is called Declarative JS Components with Vloader.js. And it was posted back in 2013, and it was about the idea of attaching JS behavior to chunks of HTML. So you can see that people were thinking about something like that.

And that's what islands are. You are selectively and progressively enhancing bits of server-side rendered HTML with some client-side JavaScript. And you have small focus chunks of interactivity within those SSR pages. And it's a bit of a mind shift, because you're going from this model where you have a single app in control of the full rendering of the page. To a place where you have actually multiple entry points. Also, usually with an island, this script for the islands can be delivered and hydrated independently. And it allows the rest of the page to be just a static HTML. But differently from other approaches to progressive hydration here, you have more specificity around how this enhancement occurs.

Another thing great about islands is that these days we have many ways to leverage them, so we have stand-alone implementations like Astro, Quake, Markle, and many others. And you can also use different tools to do islands with Preact, with Solid, with Svelte. And one interesting thing about islands is Markle. So Markle was there since 2014, it was open-sourced a few years later. But Markle shipped with this very interesting combo of streaming, with automatic partial hydration, and a clever compiler that would basically generate optimized code depending on where it was going to run on the client and on the server. Markle also had automatic partial hydration that basically allowed those interactive components to hydrate themselves. And the hydration code, of course, was only shipped for the components that needed interaction. Years later, we got Astro, and most of you heard about Astro, so in 2021. And Astro again had a very interesting combo. So by default, it was shipping 0 JavaScript, and every island could be loaded in parallel. Markle was also multi-framework, so you could build islands with React, Preact, Vector, and many others. And Astro allowed you to specify the loading strategy for each of your islands. So for example, if you're using a React JSX component with Astro and you're importing it, and etc., you can do things like this. So you can specify if that's going to be hydrated upon loading or when the browser's idle or only when your component gets visible. And you can do even more complex stuff.

That's what's great about islands in general. You're reducing the amount of JavaScript code that is shipped to the client also you can get faster page loads and better metrics related to that like TTI and others. And overall, you're making the key content of your site or your app available faster to the user.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Simplifying Server Components
React Advanced Conference 2023React Advanced Conference 2023
27 min
Simplifying Server Components
Top Content
Server Components are arguably the biggest change to React since its initial release but many of us in the community have struggled to get a handle on them. In this talk we'll try to break down the different moving parts so that you have a good understanding of what's going on under the hood, and explore the line between React and the frameworks that are built upon it.
A Guide to React Rendering Behavior
React Advanced Conference 2022React Advanced Conference 2022
25 min
A Guide to React Rendering Behavior
Top Content
React is a library for "rendering" UI from components, but many users find themselves confused about how React rendering actually works. What do terms like "rendering", "reconciliation", "Fibers", and "committing" actually mean? When do renders happen? How does Context affect rendering, and how do libraries like Redux cause updates? In this talk, we'll clear up the confusion and provide a solid foundation for understanding when, why, and how React renders. We'll look at: - What "rendering" actually is - How React queues renders and the standard rendering behavior - How keys and component types are used in rendering - Techniques for optimizing render performance - How context usage affects rendering behavior| - How external libraries tie into React rendering
Building Better Websites with Remix
React Summit Remote Edition 2021React Summit Remote Edition 2021
33 min
Building Better Websites with Remix
Top Content
Remix is a new web framework from the creators of React Router that helps you build better, faster websites through a solid understanding of web fundamentals. Remix takes care of the heavy lifting like server rendering, code splitting, prefetching, and navigation and leaves you with the fun part: building something awesome!
Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
Do you have a large product built by many teams? Are you struggling to release often? Did your frontend turn into a massive unmaintainable monolith? If, like me, you’ve answered yes to any of those questions, this talk is for you! I’ll show you exactly how you can build a micro frontend architecture with Remix to solve those challenges.
React Compiler - Understanding Idiomatic React (React Forget)
React Advanced Conference 2023React Advanced Conference 2023
33 min
React Compiler - Understanding Idiomatic React (React Forget)
Top Content
React provides a contract to developers- uphold certain rules, and React can efficiently and correctly update the UI. In this talk we'll explore these rules in depth, understanding the reasoning behind them and how they unlock new directions such as automatic memoization. 
Using useEffect Effectively
React Advanced Conference 2022React Advanced Conference 2022
30 min
Using useEffect Effectively
Top Content
Can useEffect affect your codebase negatively? From fetching data to fighting with imperative APIs, side effects are one of the biggest sources of frustration in web app development. And let’s be honest, putting everything in useEffect hooks doesn’t help much. In this talk, we'll demystify the useEffect hook and get a better understanding of when (and when not) to use it, as well as discover how declarative effects can make effect management more maintainable in even the most complex React apps.

Workshops on related topic

React Performance Debugging Masterclass
React Summit 2023React Summit 2023
170 min
React Performance Debugging Masterclass
Top Content
Featured WorkshopFree
Ivan Akulov
Ivan Akulov
Ivan’s first attempts at performance debugging were chaotic. He would see a slow interaction, try a random optimization, see that it didn't help, and keep trying other optimizations until he found the right one (or gave up).
Back then, Ivan didn’t know how to use performance devtools well. He would do a recording in Chrome DevTools or React Profiler, poke around it, try clicking random things, and then close it in frustration a few minutes later. Now, Ivan knows exactly where and what to look for. And in this workshop, Ivan will teach you that too.
Here’s how this is going to work. We’ll take a slow app → debug it (using tools like Chrome DevTools, React Profiler, and why-did-you-render) → pinpoint the bottleneck → and then repeat, several times more. We won’t talk about the solutions (in 90% of the cases, it’s just the ol’ regular useMemo() or memo()). But we’ll talk about everything that comes before – and learn how to analyze any React performance problem, step by step.
(Note: This workshop is best suited for engineers who are already familiar with how useMemo() and memo() work – but want to get better at using the performance tools around React. Also, we’ll be covering interaction performance, not load speed, so you won’t hear a word about Lighthouse 🤐)
Concurrent Rendering Adventures in React 18
React Advanced Conference 2021React Advanced Conference 2021
132 min
Concurrent Rendering Adventures in React 18
Top Content
Featured WorkshopFree
Maurice de Beijer
Maurice de Beijer
With the release of React 18 we finally get the long awaited concurrent rendering. But how is that going to affect your application? What are the benefits of concurrent rendering in React? What do you need to do to switch to concurrent rendering when you upgrade to React 18? And what if you don’t want or can’t use concurrent rendering yet?

There are some behavior changes you need to be aware of! In this workshop we will cover all of those subjects and more.

Join me with your laptop in this interactive workshop. You will see how easy it is to switch to concurrent rendering in your React application. You will learn all about concurrent rendering, SuspenseList, the startTransition API and more.
React Hooks Tips Only the Pros Know
React Summit Remote Edition 2021React Summit Remote Edition 2021
177 min
React Hooks Tips Only the Pros Know
Top Content
Featured Workshop
Maurice de Beijer
Maurice de Beijer
The addition of the hooks API to React was quite a major change. Before hooks most components had to be class based. Now, with hooks, these are often much simpler functional components. Hooks can be really simple to use. Almost deceptively simple. Because there are still plenty of ways you can mess up with hooks. And it often turns out there are many ways where you can improve your components a better understanding of how each React hook can be used.You will learn all about the pros and cons of the various hooks. You will learn when to use useState() versus useReducer(). We will look at using useContext() efficiently. You will see when to use useLayoutEffect() and when useEffect() is better.
React, TypeScript, and TDD
React Advanced Conference 2021React Advanced Conference 2021
174 min
React, TypeScript, and TDD
Top Content
Featured WorkshopFree
Paul Everitt
Paul Everitt
ReactJS is wildly popular and thus wildly supported. TypeScript is increasingly popular, and thus increasingly supported.

The two together? Not as much. Given that they both change quickly, it's hard to find accurate learning materials.

React+TypeScript, with JetBrains IDEs? That three-part combination is the topic of this series. We'll show a little about a lot. Meaning, the key steps to getting productive, in the IDE, for React projects using TypeScript. Along the way we'll show test-driven development and emphasize tips-and-tricks in the IDE.
Web3 Workshop - Building Your First Dapp
React Advanced Conference 2021React Advanced Conference 2021
145 min
Web3 Workshop - Building Your First Dapp
Top Content
Featured WorkshopFree
Nader Dabit
Nader Dabit
In this workshop, you'll learn how to build your first full stack dapp on the Ethereum blockchain, reading and writing data to the network, and connecting a front end application to the contract you've deployed. By the end of the workshop, you'll understand how to set up a full stack development environment, run a local node, and interact with any smart contract using React, HardHat, and Ethers.js.
Designing Effective Tests With React Testing Library
React Summit 2023React Summit 2023
151 min
Designing Effective Tests With React Testing Library
Top Content
Featured Workshop
Josh Justice
Josh Justice
React Testing Library is a great framework for React component tests because there are a lot of questions it answers for you, so you don’t need to worry about those questions. But that doesn’t mean testing is easy. There are still a lot of questions you have to figure out for yourself: How many component tests should you write vs end-to-end tests or lower-level unit tests? How can you test a certain line of code that is tricky to test? And what in the world are you supposed to do about that persistent act() warning?
In this three-hour workshop we’ll introduce React Testing Library along with a mental model for how to think about designing your component tests. This mental model will help you see how to test each bit of logic, whether or not to mock dependencies, and will help improve the design of your components. You’ll walk away with the tools, techniques, and principles you need to implement low-cost, high-value component tests.
Table of contents- The different kinds of React application tests, and where component tests fit in- A mental model for thinking about the inputs and outputs of the components you test- Options for selecting DOM elements to verify and interact with them- The value of mocks and why they shouldn’t be avoided- The challenges with asynchrony in RTL tests and how to handle them
Prerequisites- Familiarity with building applications with React- Basic experience writing automated tests with Jest or another unit testing framework- You do not need any experience with React Testing Library- Machine setup: Node LTS, Yarn