Remix.run Logo
geon 8 hours ago

Is there a library that can work with JSX? I'd like to render JSX on the server and only send the diff to the client. I started writing some experimental code, but it was a lot of work.

https://github.com/geon/react-node-diff/blob/main/src/diff-r...

igor47 an hour ago | parent | next [-]

Wait but, don't you render the jsx to html? So you you can still perform the diff on the rendered html?

Also, how do you know what you rendered last time? When you do the diff between what's in the browser and what the server just gave you, you have both sides. If you do it server side, you could... Render twice, once before and once after the state change? Or keep a server side cache?

geon 23 minutes ago | parent [-]

The server would keep a copy of the virtual dom during the session. Each change would be diffed and the diff sent to the client to apply. The client would only apply apply changes from the server, not change the dom on its own, so they wouldn’t get out of sync.

I can render to html, but then I’d need to parse the html back do diff it. Seems stupid.

I tried building a redux-style spa like that. Worked fine. https://github.com/geon/server-side-spa/tree/main/src/server

cetinsert 7 hours ago | parent | prev [-]

See https://github.com/tbranyen/diffhtml?tab=readme-ov-file#feat...