Frameworks
After today, you can explain what React and Next.js do for a team, and how rendering on the server or in the browser changes what users see first.
Dip your toes 1 min
A framework is a ready-made structure for building an app’s screens, and React and Next.js are the ones you’ll hear about most. React lets engineers describe what a screen should look like for any data, then redraws only what changed. Tap the plus on a Netflix title card, and every place showing that title updates together, because they all read the same data. Next.js, built on React, can build a page on a server so it appears quickly. There’s a catch a designer should know: a page can look finished before it responds to taps. In 2018, Netflix took React out of the browser on its signed-out homepage, and the wait before the page responded fell by about half.
The full lesson 10 min
Why this exists
Netflix’s browse screen is rows of title cards, and the same card appears hundreds of times. Hover over one and it grows into a preview. Tap the plus button and it becomes a check mark. The title also appears in the My List row from Day 6, and its detail page now shows it as saved. One tap, three places on the screen that have to agree.
Before modern frameworks, developers kept screens like this in sync by hand. Day 8 showed the DOM, the live tree of elements the browser draws. Code would find the button in the DOM and swap its icon.
Then it would find the My List row and insert a card. Then it would find the detail page’s button and change that too. Every interaction was a list of instructions, and every instruction was a chance to forget one.
On a small page, that’s manageable. On a screen with dozens of interactions, built by dozens of engineers, it isn’t. The bugs that result are hard to find, because each one depends on the exact order things happened. Day 3 defined a framework as code that sets your app’s structure and calls your code. React and the frameworks built on it exist to end this whole class of bug.
What it is
React’s idea is to stop writing instructions for changing the screen. Instead, you describe what the screen should look like for any given data. React works out what to change. You build that description from components, and you feed it state.
A component is a reusable piece of interface, like a title card or a button, written once in code and used anywhere. Netflix’s rows could reuse one title card component for every show. Here’s a simplified sketch of one in React:
function TitleCard({ title, inMyList }) {
return (
<div className="title-card">
<h3>{title}</h3>
<button>
{inMyList ? "In My List" : "Add to My List"}
</button>
</div>
);
}
The first line names the component and the inputs it receives, which React calls props. Here the props are a title and whether it’s in your list. The rest describes the card for any value of those inputs. The line with the question mark is a choice between two labels. If the title is in your list, the button shows the first label, and otherwise the second.
Nowhere does the code say how to change the button. It only says what the button shows.
State is the data a screen depends on at a given moment, and it changes as people use the app. Whether a title is in your list is state. So is which row you’re hovering over, what you’ve typed in the search box, and whether a request is still loading.
When state changes, React runs the affected components again with the new values. It compares the new result with the old one and changes only the parts of the DOM that differ. Engineers sum it up as “UI is a function of state.” The screen is whatever the components produce from the current state.
That’s what removes the bug from Figure 1. The card, the My List row, and the detail page all read the same piece of state. Change it once, and React redraws every place that depends on it. Nobody has to remember the third place, because nobody writes instructions for any of them. The work moves from keeping the screen in sync to deciding what the state is.
The other half of a framework’s job is rendering, which means turning components and state into something the browser can show. It can happen in two places. In client-side rendering, the browser receives a nearly empty HTML file and a batch of JavaScript. The JavaScript runs, builds the page, and only then does anything appear. The browser is the client here, the program asking for the page.
In server-side rendering, a server runs the same components for each request and sends back finished HTML. The browser can show that HTML at once. The JavaScript still has to arrive and run before anything on the page responds to a tap. That last step is hydration. JavaScript attaches to the HTML already on screen, turning a page you can see into a page you can use.
React on its own leaves those choices to each team. Next.js is a framework built on React that makes them for you, with server rendering as the starting point.
In its current App Router, every page, and every layout (the shared frame around pages), is a Server Component by default. That means it renders on the server, and its code never ships to the browser. A file marked with the line "use client" becomes a Client Component. It renders on the server for the first view, then runs again in the browser, where it can hold state and respond to taps. Interactive pieces go there.
How it shows up in your work
When engineers build your design system in code, its component library mirrors the one in your design files, piece by piece. Variants in your design tool usually map to props: size, tone, whether an icon shows. On plans that include it, Figma’s Code Connect links a Figma component to its code component. Developers in Dev Mode then see the team’s real code, not generated snippets.
A new variant of an existing component is often a small change. A new component that behaves differently is a bigger one, because someone has to decide what state it holds. Every state that component can be in, like loading, disabled, or selected, is a screen you should design.
You’ll also hear engineers ask where a piece of state lives. If only one component needs it, it lives inside that component. If several need it, it moves up to a shared parent, or into a store: a shared container of state the whole app can read. That’s why a request like “keep my filters when I come back to this page” can be bigger than it sounds. The state has to move somewhere that outlives the page.
Architecture conversations are the next. In a Next.js app, “we’ll do that on the server” can mean two different servers. One is the Next.js server, which renders pages and asks APIs for data. The other is the backend, where the business rules and databases live, often in another language.
Engineers still call the whole Next.js app frontend code, because the frontend team owns it, even though part of it runs on a server. The difference matters when you ask for something new. A change in how a page is laid out lives in the Next.js app, usually owned by frontend engineers. A change in who can see what lives in the backend, usually owned by another team. Knowing which server someone means tells you who has to say yes.
The third place is interactivity. Every filter, live control, or interaction that remembers something needs a Client Component. Simple hover effects and transitions can often be done with CSS alone. Every Client Component adds JavaScript the browser must download and run.
A page that’s mostly reading, like an article or a pricing page, can ship very little. A page full of live controls ships a lot more. When you design a rich interaction for a page that was mostly static, you’re also asking for that page to get heavier.
The one thing people get wrong
Seeing a page and using it feel like the same moment. With server-side rendering, they aren’t. The HTML arrives first and looks finished, and the buttons look ready. But until hydration completes, a tap may do nothing, or get lost.
On a fast laptop the gap is short enough to miss. On a mid-range phone on a weak connection, it can last long enough for someone to tap twice and give up.
Neither approach is faster in every way. Client-side rendering shows nothing until everything is ready. Server-side rendering shows content sooner but opens a gap between seeing and using.
Teams choose per page, and often per part of a page, based on what people do there first. A page people mostly read benefits from server rendering. A page people mostly operate, like an editor, often doesn’t gain much from it.
Netflix made this trade in public. In a 2018 case study by Google’s Addy Osmani, Netflix kept React on the server for its signed-out homepage but removed it from the browser. The page shed about 200 kilobytes of JavaScript, and the time until it responded to input fell by about half.
That page is mostly reading: a headline, some artwork, and a field for your email address. Very little on it needed React in the browser. The page looked the same before and after. What changed was how long the gap lasted.
For design, the gap is something to plan for. Ask what the first tap on a page will be, and whether it needs JavaScript to work. A link to another page works as soon as it’s visible. A custom dropdown or a sign-up form built from Client Components may not.
Put the first important action in the part of the page that works earliest; frameworks only make that possible.
Ask an engineer this
“Which parts of this page render on the server and which in the browser, and what does someone see and tap before the JavaScript arrives?”
This works best while you’re both looking at a page you’re about to redesign. Ask the engineer to split the page into parts: what arrives as finished HTML, and what waits for JavaScript. Find out which interactive pieces load late, and whether anyone has watched the page load on a slow phone. The follow-up that matters is what a person sees if they tap during that gap. From there, you can tell which parts of your design are safe to put first, and which ones need a fallback.
Terms from today
- Component
- A reusable piece of interface, like a title card or a button, written once in code and used anywhere the screen needs it.
- State
- The data a screen depends on at a given moment, like whether a title is in your list, which changes as people use the app.
- Client-side rendering
- Building a page in the browser with JavaScript, so content appears only after that code has downloaded and run.
- Server-side rendering
- Building a page’s HTML on a server for each request, so the browser can show content before its JavaScript runs.
- Hydration
- The step where JavaScript in the browser attaches to server-rendered HTML, turning a page you can see into one you can use.