AI summary by TwinMind
React vs HTMX - A Fascinating War
Theo - t3․gg
22m 23s
React Server Components & New Architecture Discussion
- Blog post by Boba Kang comparing React, Solid, and HTMX approaches
- React Server Components (RSCs) best understood as part of "new React architecture" not in isolation
- Biggest failure: lack of term for comprehensive changes (unlike Vue3 vs Vue2, Angular2 vs AngularJS)
- Everything remains backwards compatible, making version changes unclear
- RSCs are server-client architecture speaking React on both ends
- Grants components on server direct access to computing environments/resources
- New architecture is unified model for UI development under single coherent paradigm
- True "one-app architecture" vs external server-side features (getServerSideProps, loaders/actions)
- Challenges: waterfall issues still exist but hidden from network tab
- Increased bundle size and early-stage tooling support
- Server-side waterfalls significantly less problematic than client-side
- Server already authenticated, no re-authentication needed
- Can stream results efficiently
- Author believes these are growing pains, not critical deficiencies
- Predicts 2024 as year everything "clicks for mainstream audience"
Solid Framework Analysis & 2023 Success
- Author claims Solid "won JS frontend in 2023" due to ideas, not usage
- T3 Awards 2023: Solid won web framework of the year
- Most frameworks implemented signals, React adopted reactivity language for compiler
- Solid 2.0 and Solid Start 1.0 coming in 2024
- Real point of Solid: primitives over abstractions, explicit over implicit, simplicity over ease of use
- Key distinction: Simplicity vs ease of use
- Svelte example:
let count = 0(easier) vs React useState (simpler) - Svelte Runes moved toward more explicit approach for better scalability
- Ease of use helps snippets/samples, simplicity helps solve hard problems over time
- Svelte example:
Solid's Server Strategy
- Not creating own server components, betting on server functions
- Server functions similar to React server actions (use server directive)
- Leveraging React ecosystem primitives (JSX, bundler features) for non-React framework
- Combined with router/data API offers: caching, route-level parallel fetching
- "Best of Relay, TanStack Query, tRPC, and Remix in single package"
- Solid components more like setup functions (run once) vs render functions (continual reruns)
- Smaller potential gain from moving components to server vs React
- Already minimal bundle size and cheap hydration costs
- Approach doesn't require radical mental model shift
- Still client-centric with additional primitives bringing server closer
HTMX Rise and Philosophy
- Unexpected entrance to JS framework war in 2023
- Single JS file library, gained 15,000 GitHub stars
- Second place in 2023 JavaScript Rising Stars (frontend framework category)
- Not new library (late 2020, predecessor Intercooler 1.0 in 2016)
- Fundamentally opposite approach to mainstream SPA/React patterns
- Extends HTML as hypermedia with sophisticated behaviors as attributes
- Opposite of JSX: HTML writes behaviors vs JavaScript writes template
- Server-centric like "web old days" but matches SPA interactivity
- Little to no client-side scripting required
Framework Comparison & Trade-offs
- HTMX shows different route to one-app architecture by eliminating client-side
- Important limitation: interactivity ceiling much lower than React/Solid
- Historical context: Backend/frontend separation bridged by GraphQL/JSON APIs
- Next.js enabled crossing backend/frontend line with React
- HTMX enables backend developers to skip frontend team for basic interactivity
- Gets 80% of functionality with radically less complexity
- No extra dependencies, build steps, advanced tooling, state management, hydration issues
- Question: "What are you really building? Does it need more than HTMX?"
Virtual DOM vs Fine-grained Reactivity
- React virtual DOM: full component representation in memory, requires hydration
- Solid: creates tree of state, not components; minimal hydration needed
- Solid ships less JavaScript, runs less JavaScript
- Different mental models for handling server-client relationship
Future Predictions & Conclusions
- Network chasm cannot be closed, only crossed
- Three distinct approaches:
- React: cover full spectrum within same component model
- Solid: client-side focus with primitives bringing server closer
- HTMX: server-centric with supercharged hypermedia
- No silver bullet, different trade-offs benefit different use cases
- Author believes all approaches have merit for different scenarios
