Abracadabra: The Vanishing Network

Bookmark
Rate this content

The network that stands between our server and the client is what causes the most complexity in our development process. Whether it be the initial UI we generate on the server, the API calls we make as the user navigates around, or the form submissions our user makes, keeping the application responsive and up-to-date is a massive chore.

What would it be like if all of that complexity just disappeared? Freaking great, that's what it would be like. And React Server Components and Actions are what's making that possible. In this talk we'll look into how that's happening and how we can take advantage of this amazing developer experience to deliver even better user experiences.

This talk has been presented at React Summit US 2024, check out the latest edition of this React Conference.

FAQ

The shift from multi-page apps to single-page apps was driven by the desire to improve user experience by avoiding full-page refreshes and reducing template duplication between the server and client.

The speaker suggests optimizing for change by making it easy to refactor and adapt code over time rather than over-abstracting logic into separate files.

The trade-off involves dealing with some complexity from using compiler directives, but it simplifies the integration of server and client logic, potentially reducing network-related code.

Progressive enhancement is important for ensuring that applications work for users with varying levels of JavaScript support, enhancing the user experience while maintaining backward compatibility.

The speaker recommends using Playwright for end-to-end testing and focuses on integration tests as part of their testing strategy, aligning with the testing trophy philosophy.

Pespa, or the progressively enhanced single-page app architecture, involves using frameworks like Remix to combine the benefits of server-side rendering with client-side enhancements for improved user experience.

The speaker prefers Remix because it aligns with their preferred methodology for building apps, offering a different approach to handling server-side rendering and client-side functionality.

The speaker took two weeks to add a checkbox due to the complexity of managing network operations and dealing with a large, complex codebase rather than the UI itself, which was simple.

Modern React with server components improves the process by allowing developers to write server-only logic that can be referenced in client-side code without duplicating logic, thus reducing network code complexity.

Kent C. Dodds
Kent C. Dodds
32 min
19 Nov, 2024

Comments

Sign in or register to post your comment.
Video Summary and Transcription
I am so excited to share my software development experience. The talk focuses on React and the Vanishing Network, aiming to make network management disappear. It starts with the multi-page app paradigm and moves towards enhancing user experience and transitioning to single-page app architecture. The talk discusses eliminating duplication, transitioning to a JSON API, and utilizing React and user actions. It explores progressive enhancement with Remix, moving to modern React with server components, and enhancing server-client communication and UI. It also covers server-client code separation, Epic React version two, AI plugins, Next.js, trade-offs, testing, SQL queries, and optimizing for change.
Available in Español: Abracadabra: La Red Desaparecida

1. Introduction to React and the Vanishing Network

Short description:

I am so excited to be here and share my software development experience. I had an internship where I had to add a checkbox to an app. The code was complex, but the UI was easy. The job was tough due to network management. I want to make the network disappear and discuss it in this talk. It's based on a free workshop called React and the Vanishing Network.

I am so excited to be here, and I've got so much to share with you, so I'm thrilled that we don't have to do this. We just did that. So we're going to get right into story time.

When I was just getting into software development, I had an internship at a company called Domo, and we built an app that was a business intelligence app. This was BI before AI was too popular. And watch your eyes. This is the only bright slide that I have for you, but it's going to blind you. And now I can see you.

So this is the app, and I was asked as the intern to add a checkbox. It wasn't actually this checkbox because the UI looks completely different now than it did then, but we're going to imagine. I was asked to add that checkbox. Here's the code for that. It was a backbone model and view. We're going to look at this in detail. So that's our model. And then here's a bit from our view. No, just kidding. We're not going to look at that. And it actually isn't the code, either. That was ChatGBT. But it was a backbone stuff. It was a 1,000 line model, a 2,000 line base view, and a 1,000 line view that extended the base view. That's what I had to work with to add this checkbox. It took me all of, like, five minutes to add the UI for that.

But I want to know, just shout it out because I can't see if you raise your hands. How long do you think it took me to add this feature? Two sprints? A day? Two hours? Five months, OK. It took me two weeks. And I'm like the intern trying to prove myself, and I did. Yeah, I proved that I am incompetent, I guess. It was just so sad. Why do you think it took so long? Shout this out. Complexity. OK, so in general, complexity. Yeah, there was a lot of code. What specifically makes this job so complex? JavaScript. Yeah, you're not wrong. It's network management. The loading the data and doing the mutation. Adding the UI was like super fast. That was not hard. It's just an HTML template in my backbone view, but managing that network, man, that was tough. And that's what made it take two weeks. So I want to make the network completely vanish, completely disappear. And so that's why we're going to see what is happening to our network code in our applications.

The rest of my talk is based on a workshop that is completely free. You can go through the entire thing yourself. And that's what we're going to go through here. It's the React and the Vanishing Network. You can check this out later. We're going to be moving kind of quick through this.

2. Exploring the Multi-Page App Paradigm

Short description:

So we're starting with the multi-page app paradigm. We generate HTML, get a count from the database, and render it. We make a form to update the count, handle the route, convert form data, update the count, and redirect. There's minimal network code, but we moved on for better user experience. Clicking on the button causes a full page refresh, hindering quick increments for keyboard users.

So I checked it before, and you should be able to see that. If not, I am so sorry. I did my best. But yeah, we're going to start with the multi-page app paradigm where we all started. So we've got this simple app serving from the slash.

We're going to generate some HTML. So let's get a count from our database. We're going to render that count out here. And here, let's save that and make sure that we're in a good spot. Boom. Count zero. Magic. The web still works. Always bet on the web.

Now we're going to make a form so that we can update this. And so we're posting to update count. And then we have these buttons that can have a name and a value. Did you know that? That's a cool thing. So whichever one we click is what's going to be sent to the back end. So that's cool. Now if I try to click on one of those, it's not going to work because we're going to that route and we're not handling that route. So let's handle that route now. We're going to handle a post to update count. We've got our form data. We're going to convert that into a number because that goes over as a string. We're going to update the count, change it, buy that change, and then redirect because we're doing post redirect get. If you don't know what that means, then ask your elders. And we're going to decrement and increment. There we are. Awesome. It works. OK, so let's take a look at the network code. Where is the network code in here? Well, there's not actually a lot. But there is some. Some code related to the network. We've got this slash here. That's the URL. It's very much attached to the network. Our action is being defined here. So that's kind of network code too. Even our method that's related to the network. And then, of course, handling that and doing the redirect. All of that is sort of related to the network. Or pretty close. But there's really not a whole lot of network code in here. And this is why a lot of people who built apps using the multi-page app architecture really lament the way that we do things now because it really is that simple. But there's a reason we moved on from this. And the reason is user experience. So we want to have a much better user experience because right now what we're getting is a full page refresh every time we click on this. And so if I wanted to increment really quickly and I was a keyboard user, I'm going to tap, tap, increment, tap, tap, increment, tap, tap, increment.

QnA

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 2023React Advanced 2023
27 min
Simplifying Server Components
Top Content
Watch video: Simplifying Server Components
React server components simplify server-side rendering and provide a mental model of components as pure functions. Using React as a library for server components allows for building a basic RSC server and connecting it to an SSR server. RSC responses are serialized virtual DOM that offload code from the client and handle interactivity. The client manifest maps serialized placeholders to real components on the client, enabling dynamic rendering. Server components combine the best of classic web development and progressive enhancement, offering the advantage of moving logic from the client to the server.
Exploring React Server Component Fundamentals
React Day Berlin 2023React Day Berlin 2023
21 min
Exploring React Server Component Fundamentals
Top Content
Watch video: Exploring React Server Component Fundamentals
This Talk introduces React Server Components (RSC) and explores their serialization process. It compares RSC to traditional server-side rendering (SSR) and explains how RSC handles promises and integrates client components. The Talk also discusses the RSC manifest and deserialization process. The speaker then introduces the Waku framework, which supports bundling, server, routing, and SSR. The future plans for Waku include integration with client state management libraries.
And Now You Understand React Server Components
React Summit 2024React Summit 2024
27 min
And Now You Understand React Server Components
Top Content
In this Talk, Kent C. Dodds introduces React Server Components (RSCs) and demonstrates how to build them from scratch. He explains the process of integrating RSCs with the UI, switching to RSC and streaming for improved performance, and the benefits of using RSCs with async components. Dodds also discusses enhancements with streaming and server context, client support and loaders, server component rendering and module resolution, handling UI updates and rendering, handling back buttons and caching, and concludes with further resources for diving deeper into the topic.
A Practical Guide for Migrating to Server Components
React Advanced 2023React Advanced 2023
28 min
A Practical Guide for Migrating to Server Components
Top Content
Watch video: A Practical Guide for Migrating to Server Components
React query version five is live and we'll be discussing the migration process to server components using Next.js and React Query. The process involves planning, preparing, and setting up server components, migrating pages, adding layouts, and moving components to the server. We'll also explore the benefits of server components such as reducing JavaScript shipping, enabling powerful caching, and leveraging the features of the app router. Additionally, we'll cover topics like handling authentication, rendering in server components, and the impact on server load and costs.
Server Components: The Epic Tale of Rendering UX
React Summit 2023React Summit 2023
26 min
Server Components: The Epic Tale of Rendering UX
Top Content
Watch video: Server Components: The Epic Tale of Rendering UX
This Talk introduces server components in React, which provide an intermediate format for rendering and offer advantages for both client-side and server-side rendering. Server components reduce bundle size on the client and improve search engine optimization. They abstract the rendering process, allowing for faster rendering and flexibility in choosing where to render components. While server components are still in the experimental stage, Next.js is a good starting point to try them out.
RSCs In Production: 1 Year Later
React Summit 2024React Summit 2024
24 min
RSCs In Production: 1 Year Later
This Talk explores the experience of shipping server components in production and highlights the benefits and challenges of using Server Components in Next.js apps. The Talk discusses the deployment of UploadThing and the use of AppRouter for safe production usage. It delves into the implementation of different layouts, data fetching, and code centralization for improved performance. The Talk also covers the use of server components for performance optimization and latency handling. Additionally, it explores the use of Edge and Lambda for partial pre-rendering and the challenges faced with webpack performance and hydration. Overall, the Talk emphasizes the benefits and challenges of working with Server Components in Next.js applications.

Workshops on related topic

Mastering React Server Components and Server Actions in React 19
React Summit US 2024React Summit US 2024
150 min
Mastering React Server Components and Server Actions in React 19
Featured Workshop
Maurice de Beijer
Maurice de Beijer
Calling all React developers! Join us for an immersive 4-hour workshop diving deep into React Server Components and Server Actions. Discover how these game-changing technologies are revolutionizing web development and learn how to harness their full potential to build lightning-fast, efficient applications.

Explore the world of React Server Components, seamlessly blending server-side rendering with client-side interactivity for unmatched performance and user experience. Dive into React Server Actions to see how they combine client-side interactivity with server-side logic, making it easier to develop interactive applications without traditional API constraints.

Get hands-on experience with practical exercises, real-world examples, and expert guidance on implementing these technologies into your projects. Learn essential topics such as the differences between Server and Client Components, optimizing data fetching, passing data effectively, and maximizing performance with new React hooks like useActionState, useFormStatus and useOptimistic.

Whether you're new to React or a seasoned pro, this workshop will equip you with the knowledge and tools to elevate your web development skills. Stay ahead of the curve and master the cutting-edge technology of React 19. Don't miss out - sign up now and unleash the full power of React!
Next.js 13: Data Fetching Strategies
React Day Berlin 2022React Day Berlin 2022
53 min
Next.js 13: Data Fetching Strategies
Top Content
Workshop
Alice De Mauro
Alice De Mauro
- Introduction- Prerequisites for the workshop- Fetching strategies: fundamentals- Fetching strategies – hands-on: fetch API, cache (static VS dynamic), revalidate, suspense (parallel data fetching)- Test your build and serve it on Vercel- Future: Server components VS Client components- Workshop easter egg (unrelated to the topic, calling out accessibility)- Wrapping up
The Gateway to Backend: A Frontend Developer's Guide to Full-Stack Development
React Summit US 2023React Summit US 2023
160 min
The Gateway to Backend: A Frontend Developer's Guide to Full-Stack Development
Top Content
Workshop
Amy Dutton
Amy Dutton
This workshop will guide you through the product development life cycle of creating a real-world web application. You will learn about React Server Components, building a design system within Storybook, and using frontend development to approach becoming a full-stack developer. The workshop will cover increasing confidence in your application with unit tests and implementing authentication and authorization. You'll have the opportunity to work through product features and examine a real-world RedwoodJS project, gaining valuable experience in real-world product development. RedwoodJS makes it simple to approach full-stack development, and this workshop will give you the skills you need to create your own real-world web applications.
Advanced Application Deployment Patterns with React Server Components (feat. a DIY RSC Framework)
React Summit US 2023React Summit US 2023
104 min
Advanced Application Deployment Patterns with React Server Components (feat. a DIY RSC Framework)
Top Content
Workshop
 Greg Brimble
Greg Brimble
The developer ecosystem is always moving fast and this year has proved no exception. React Server Components can offer a significant improvement to developer experience and to application performance. But I think it's fair to say that this new server-first paradigm can be tricky to wrap your head around!In the first half of this workshop, we'll explore React Server Components from the ground-up: building our own mini meta-framework to help us understand how RSCs work. We'll discover exactly what is produced by an RSC build and we'll connect those pieces together to form a full application.Next, we'll deploy it! Cloudflare have also had a busy year too — Smart Placement, in particular, is a new technology that we've developed which fits the RSC model perfectly. We'll explore why that makes sense for our workshop app, and we'll actually deploy it onto the Cloudflare Developer Platform.Finally, we'll build out our app a little further, using D1 (our serverless SQL database) to really show off the React Server Component's power when combined with Smart Placement.You should come away from this workshop with a greater understanding of how React Server Components work (both behind-the-scenes and also how you as a developer can use them day-to-day), as well as insight into some of the new deployment patterns that are now possible after recent innovations in the platform space.
Building Reusable Server Components in NextJS
React Summit US 2023React Summit US 2023
88 min
Building Reusable Server Components in NextJS
Workshop
Will Bishop
Mettin Parzinski
2 authors
React continues to evolve their beta capability, React Server Components, and they're continuing to further develop them in partnership with frameworks like NextJS.In this workshop, attendees will learn what React Server Components are, how to effectively build and use them in NextJS, and focus on one of the major advantages of React/NextJS: reusability through components.We will also cover related beta technologies enabled by the `app` directory, such as nested layouts and server actions (alpha/experimental capability).Join us for this hands-on, 120 minute workshop!Technologies:
React, JavaScript/Typescript, NextJS, Miro
React Server Components Unleashed: A Deep Dive into Next-Gen Web Development
React Day Berlin 2023React Day Berlin 2023
149 min
React Server Components Unleashed: A Deep Dive into Next-Gen Web Development
Workshop
Maurice de Beijer
Maurice de Beijer
Get ready to supercharge your web development skills with React Server Components! In this immersive, 3-hour workshop, we'll unlock the full potential of this revolutionary technology and explore how it's transforming the way developers build lightning-fast, efficient web applications.
Join us as we delve into the exciting world of React Server Components, which seamlessly blend server-side rendering with client-side interactivity for unparalleled performance and user experience. You'll gain hands-on experience through practical exercises, real-world examples, and expert guidance on how to harness the power of Server Components in your own projects.
Throughout the workshop, we'll cover essential topics, including:- Understanding the differences between Server and Client Components- Implementing Server Components to optimize data fetching and reduce JavaScript bundle size- Integrating Server and Client Components for a seamless user experience- Strategies for effectively passing data between components and managing state- Tips and best practices for maximizing the performance benefits of React Server Components