RSCs In Production: 1 Year Later

Rate this content
Bookmark

FAQ

UploadThing uses server components for server-side logic and client components for client-side interactions. This separation allows for efficient data fetching and rendering.

Suspense in UploadThing is used to optimize the loading experience by allowing certain components to load data asynchronously without blocking the rendering of the main content.

The NextSSR plugin in UploadThing ensures that configuration data is available both on the server and client side to prevent hydration errors and provide a seamless user experience.

Partial pre-rendering is a feature in Next.js that allows caching of the initial static part of a page on a CDN, improving load times by streaming user-specific data later.

Theo prefers using TRPC because it provides a type-safe RPC layer for TypeScript, allowing for seamless integration of backend functions in the frontend, which complements the use of server components.

Theo faced challenges with performance, especially without partial pre-rendering. He also encountered issues with developer server performance and integration of server and client components in packages.

UploadThing is deployed using Vercel, connected to a GitHub monorepo. It deploys automatically whenever code is pushed to the specified repository.

AppRouter is a new routing system in Next.js that replaces the older pages router. It allows for more flexible and efficient routing, including support for nested layouts.

UploadThing is a file uploading service that simplifies adding file upload functionality to projects. It is a Next.js application using AppRouter and Server Components.

Theo is a YouTuber and an engineer known for his work on projects like UploadThing.

Theo Browne
Theo Browne
24 min
18 Jun, 2024

Comments

Sign in or register to post your comment.
  • Rishi Narang
    Rishi Narang
    HUB
    Is there any github link that shows the code mentioned in video?
Video Summary and Transcription
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.

1. Introduction to UploadThing and Server Components

Short description:

Hi, I'm Theo, an engineer who shipped the UploadThing project. Let's dive into the experience of shipping server components in production for over a year. We learned a lot, both the great and terrible things. React Summit deserves a shout out for this opportunity.

Hi, I'm Theo. You probably know me from YouTube, but believe it or not, I'm also an engineer. Yes, I do ship code. In fact, I shipped a really big project around this time last year. You might have heard of it. It's called UploadThing. It's a thing for uploading files. This is it. This is what it looks like. It's, in my opinion, the best way to add file uploading to your project, but that's not what we're here to talk about today as much as I would love to because we need to go deep on server components. Specifically, what has it been like shipping server components in production for a bit over a year now? Yes, we went all in on AppRouter. We even went all in on Edge with this project. There's a lot of cool things we learned, a lot of cool things that worked great, and of course, a bunch that worked terribly. I want to go in detail on all of these because normally when I would do this in a video, no one would watch it. But since I have you guys all held hostage at this conference, we can talk about these things in way more depth than I normally get to. Isn't that exciting? Huge shout out to React Summit for letting me do this, recording the video, sending it ahead of time because this is such a stress relief. Wish I could have been there in person, but hopefully if all goes well next year.

2. UploadThing Deployment and AppRouter

Short description:

Let's dive into UploadThing, a traditional Next.js app deployed with AppRouter. We broke the packages and infrastructure into separate repositories to open source the packages. We've learned a lot through this process and will showcase some of the cool things we've discovered. While most of our stuff is still on Vercel, we're trying out other deployment options for certain components. We'll also discuss AppRouter, which is crucial for using Server Components safely in production. If you need more background, check out my YouTube videos on the pages router in Next.js.

Anyways, let's dive in. I have a whole list of the good, bad, and ugly and I want to go through all these parts.

Okay, first things first, what is this app and how is it deployed? Well, UploadThing is a pretty traditional Next.js application using AppRouter. We can take a look in our Vercel PENG account, hop over to UploadThing and you see nothing too exciting here. We were using FileThing as our original name, but UploadThing is what we ended up sticking with. It's hooked up to a GitHub repo. It deploys automatically. The GitHub repo is where things start to get a bit more interesting though, because the GitHub repo is a monorepo.

Originally, we had the packages for UploadThing as well as the infrastructure all in one repository. We broke them apart because we wanted to open source all of the packages. So if you're curious how the packages work, we're not talking about that too much here. That's all open source. You can feel free to dig into it. This is how our infrastructure works and we've learned so much through doing this and I can't wait to showcase some of the cool things that we've learned.

But as I said, pretty traditional, you attach this to Vercel and it deploys automatically once you tell it which of these packages that the code is in, which is in infrared slash UploadThing server. See here, we've been trying out other places to deploy more and more of our infra. We'll definitely talk about that as we go because while most of our stuff is still Vercel entirely, we are using other pieces for other things like managing our S3 buckets, managing our redirect layer on top of those. That stuff we've been doing separately. First, it's worth acknowledging that this isn't just going to be about Server Components because we also are using AppRouter, which to be frank, is the only real way to use Server Components safely in production right now. So yes, we're on AppRouter plus Server Components. We're going to have to talk about AppRouter a bunch for this to be a fair conversation. You're not already familiar. Next.js replaced their router, which was the pages router, where you just had random page.tsx files.

Well, they weren't really page.tsx. Whatever the name of the file was, that became the URL. So if you had Theo.tsx, whatever you exported there would become page slash Theo. Now, we're on AppRouter, which is a different way of doing things. I don't want to go too in depth on how things used to work. So if you need to learn about that, I have tons of videos on my YouTube channel all about how pages router worked, how it compared to this. I am expecting some amount of knowledge of Next.js as we go through.

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.
Batteries Included Reimagined - The Revival of GraphQL Yoga
GraphQL Galaxy 2021GraphQL Galaxy 2021
33 min
Batteries Included Reimagined - The Revival of GraphQL Yoga
Envelope is a powerful GraphQL plugin system that simplifies server development and allows for powerful plugin integration. It provides conformity for large corporations with multiple GraphQL servers and can be used with various frameworks. Envelope acts as the Babel of GraphQL, allowing the use of non-spec features. The Guild offers GraphQL Hive, a service similar to Apollo Studio, and encourages collaboration with other frameworks and languages.

Workshops on related topic

Next.js 13: Data Fetching Strategies
React Day Berlin 2022React Day Berlin 2022
53 min
Next.js 13: Data Fetching Strategies
Top Content
WorkshopFree
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
WorkshopFree
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
WorkshopFree
 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
Mastering React Server Components and Server Actions in React 19
React Advanced 2024React Advanced 2024
160 min
Mastering React Server Components and Server Actions in React 19
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!