JSX Over The Wire — overreacted
2 days ago
- Traditional REST APIs struggle with the tension between raw data models and UI-specific view models, leading to inefficiencies and maintenance challenges.
- The Backend for Frontend (BFF) pattern solves this by adding a server layer that returns screen-specific view models, allowing single roundtrip data loading.
- ViewModels can be decomposed into reusable functions that mirror the component tree, enabling self-contained UI elements that load their own data.
- Server-Driven UI (SDUI) treats UI as JSON, allowing the server to return entire screen trees that are rendered on the client without losing state.
- React Server Components unify these ideas: server components act as view models that emit JSON, client components consume them, ensuring direct coupling between server data and UI and preserving client state on refetches.