Skip to content

Commit 6308b2a

Browse files
committed
ssr, ssg, and rsc oh my 🦁 🐯 🐻
1 parent f238c9d commit 6308b2a

File tree

6 files changed

+43
-20
lines changed

6 files changed

+43
-20
lines changed

lessons/01-the-first-section/A-intro.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ Class Outline
3030

3131
- Rebuild the app in Next
3232

33-
# Let's do it with TanStack Start
33+
# What else is there?
3434

35-
- Rebuild the app in TanStack
35+
- React Router / Remix
36+
- (Coming Soon) TanStack Start
37+
- Vite by itself!
3638

3739
# Other options
3840

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hi React 19.

lessons/02-a-second-section/A-first-lesson.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

lessons/02-a-second-section/B-second-lesson.md

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "What is an RSC?"
3+
---
4+
5+
# TODO: split this page up into multiple page. add code examples for SSG and SSR
6+
7+
> 💡 This course assumes you have taken or at least understand the concepts in [The Complete Intro to React v9][v9]. If you don't, please go back and take that one first, this will make a lot more sense.
8+
9+
React Server Components (which I will now abbreviate as RSC) are a concept that have been teased for a few years before landing in stable React in early 2025 when React 19 was officially realeased. No doubt they are a very interesting piece of technology and offer a lot of upside. They have some interesting trade-offs and we'll talk about them, but don't be quick to paint them as bad as some have, and definitely don't use them _everywhere_ either, they have a time and place.
10+
11+
Before we dive right into what an RSC is, it's helpful to understand _three_ other ways React renders your app.
12+
13+
## Client-side React
14+
15+
This is just normal React, what your learned in the Complete Intro. Your server does nothing for you; it just sends the client browser an empty HTML page and a full bundle of JS to render your app. All React components are rendered on the client - your server does not help.
16+
17+
This is how we've written React for a very long time (10+ years now) and will continue writing React for a long time yet this way.
18+
19+
Brian's (not-so) 🔥 Take: this is the default way you should write React. Everything is a contextual performance enhancement, and should only be reached for when: 1. the performance enhancement actually meaningfully helps (it frequently doesn't) and 2. you actually have a need for the performance enhancement (you frequently don't). This style of rendering yields the simplest apps that are easiest to write, easiest to maintain, and easiest to debug.
20+
21+
## Static-Site Generation (SSG)
22+
23+
> Fun fact: this very website is rendered via SSG with Next.js! [See the code here][code]
24+
25+
Static Site generation allows you to use React to generate a fully static site. This is perfect for sites like blogs or course materials (like this site) where it's just a bunch of static pages that don't need the interactivity of React. It's enough to render this out once - it doesn't need the interactivity. The result is the end user is just shipped fully rendered flat HTML files - it doesn't need a server or client to do it. The developer can still add some interactivity via React, but minimally so.
26+
27+
This is just useful for static content. I love it because it helps me ship these courses faster, but it's not a good fit for anything with much more than basic interactivity.
28+
29+
## Server-Side Rendered (SSR)
30+
31+
This is a hybrid of the two. Essentially here on inital page load, your server will handle the initial rendering of the React app and ship rendered HTML. The full bundle of the React component will then be shipped to the client and React will "hydrate" the markup. Hydrate in this case just means it'll take the inert HTML and add anything interactive to it. In a sense, the React app "takes over".
32+
33+
SSR is a double-edged sword. It can be a huge help, saving slow devices from having to run big React apps and shaving off precious milliseconds of _time to first paint_ (but _not time to first interactive_). So as you can see, it's a tradeoff, and frequently SSR can actually make things worse, not better, so do be careful. Measure your key metrics and make sure it's helping!
34+
35+
## React Server Components
36+
37+
[v9]: https://react-v9.holt.courses
38+
[code]: https://github.com/btholt/intermediate-react-v6/
File renamed without changes.

0 commit comments

Comments
 (0)