AI summary by TwinMind

Dan Is Back, Let’s Rethink React

Theo - t3․gg

1h 15m 43s

Dan Abramov Introduction and Background

  • Dan Abramov back for React Conf talk, now working at Blue Sky (not Meta)
  • Talk titled "React for Two Computers" - evolution of his "Tale of Two Reacts" presentation
  • Blue Sky experience gave Dan real app development perspective
    • Dealt with MobX issues, bundler problems, React Native ecosystem challenges
    • Removed MobX from Blue Sky, added React Compiler, significantly improved performance
    • Provided valuable migration stories and understanding of developer pain points

Talk Format and Approach

  • Originally intended as blog post, attempted 13+ times unsuccessfully
  • Realized performance format better suited for communicating server components concepts
  • Designed to be conversational and remixable, leaving gaps for community feedback
  • Worked with Michael Chan (Chantastic) until 1am night before to finalize presentation
  • Most structured/buttoned-down talk Dan has ever given

Core Concept: Two Computers Metaphor

  • Web development involves two computers: server and client
  • Traditional request-response model: client requests page, server responds with HTML/scripts
  • HTML itself is a "script" - programming language for display instructions
  • Analogy to performance: past Dan (script writer) vs present Dan (performer)
  • Communication flows one direction through text/script between past and present

Live Coding Demo: Cat Name Generator

  • Started with hardcoded array of cat names in client-side JavaScript
  • Moved to API fetch pattern using /api/cat-names endpoint
  • Demonstrated latency issues when data must be fetched after page load
  • Problem: user expects immediate response for certain interactions

Server-Side Optimization Process

  • Moved data fetching logic from client to server
  • Eliminated separate API endpoint - integrated data fetching directly into HTML generation
  • Used JSON.stringify to embed data directly in HTML template
  • Result: no network request needed, data immediately available on page load

Key Insight: Lifting State/Data Up

  • Concept of "lifting data up" similar to lifting state up in React
  • Instead of lifting to parent component, lift to parent computer (server)
  • Move async operations from client to server where they execute first
  • Send only necessary data to client, not entire dataset

Boundaries and Program Structure

  • Removed inessential boundaries between client/server code
  • Boundaries dictated by laws of physics: server executes first, then client
  • Two-step process: server generates, client receives and executes
  • Clear separation of data flow while maintaining single program conceptual model

Component-Based Approach

  • Vanilla JavaScript approach becomes unwieldy for complex applications
  • Need for composable, reusable components with clear product feature mapping
  • Components provide abstraction and modularity missing from string interpolation approach

Server Components Introduction

  • CatNameGenerator as async server component
  • RevealButton as client component with use client directive
  • Clear file boundary separation - cannot colocate due to execution environment differences
  • Props flow from server component to client component through serializable data

The "Door" Concept - use client Directive

  • use client creates one-way door from server to client
  • Only serializable data (JSON-compatible) can pass through
  • Server sends behaviors/JavaScript to client, not just HTML
  • Matrix analogy: green code (server) vs normal appearance (client)

Component Composition and Reusability

  • Multiple instances of components work independently
  • Each component can receive different data while sharing behavior
  • Children props enable passing server-rendered content to client components
  • Server components can pass other components (server or client) as props

Advanced Patterns Demonstrated

  • Tab bar example showing pre-rendered states on server
  • Suspense integration for streaming slow components
  • Server components handle expensive operations (syntax highlighting, database queries)
  • Client only toggles between pre-rendered states without re-fetching

Streaming and Suspense Integration

  • Slow operations wrapped in Suspense don't block initial page load
  • HTML streams additional content when ready
  • Loading states handled gracefully
  • Single request streams multiple responses over time

Technical Implementation Details

  • Client components run on both server (for initial HTML) and client (for interactivity)
  • Dynamic imports with SSR: false for true client-only components
  • Hydration process matches JavaScript to server-rendered HTML
  • Props embedded in script tags for client component access

Performance and Cost Benefits

  • Reduction from N API requests to single streamed response
  • Server-side rendering more cost-effective than multiple authenticated requests
  • Eliminates redundant database connections and query processing
  • Significantly cheaper than client-side data fetching patterns

Comparison to Existing Solutions

  • Different from PHP/traditional server rendering - generates dynamic behaviors
  • Superior to HTMX/LiveView - sends custom JavaScript, not generic framework code
  • Related to GraphQL/Relay concepts but more accessible and integrated
  • Unique in combining server data fetching with client component composition

Framework Ecosystem

  • Works with Next.js, potentially other frameworks supporting React Server Components
  • Requires framework-level support, cannot be added to existing apps easily
  • Represents paradigm shift requiring new project architecture

Future Implications

  • Fundamental change in how React applications are structured
  • Harder to adopt than previous React innovations (like Compiler)
  • Requires understanding and experimentation through side projects
  • Expected to become standard for future React development

TwinMind

Get summaries like this for your own meetings

TwinMind takes notes in the background during meetings, lectures, and calls, then writes the summary for you.

Free plan to get started

No bot joins your calls

Phone, desktop & Chrome apps

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome