4 ms·
This "HTMX in React" idea just reinvented React Server Components. https://react.dev/reference/rsc/server-components https://react.dev/reference/rsc/server-comp
by dfabulich 2y ago
This "HTMX in React" idea just reinvented React Server Components. https://react.dev/reference/rsc/server-components https://react.dev/reference/rsc/server-components
An attractive future direction might be to re-implement Htmx in React:
• The server sends a JSON blob that React converts into virtual DOM components.
• That would solve the component state problem.
• It would mean we require no special bridge to use React
components.
• It would let us use our React-connected web fetching library, and carefully avoid the queuing choices made by Htmx.
• It would solve the morphdom problems and browser DOM input elements problem, too, which is pretty much a solved problem in React.
In this way, we could drop the Htmx dependency but retain the benefits of the idea. That is, given a budget to embark on such a big piece of work.
RSC is still experimental, and the default implementation assumes that you're going to run JS on the server, which undermines some of the point of HTMX.
But someday (likely in the next year or so) the RSC wire format will be standardized, and then any language can generate RSC JSON for React to consume.