Hacker News new | ask | show | jobs
by williamdclt 2288 days ago
It is standard HTML in the sense that it's valid HTML, which React JSX isn't, of course. But without the JS runtime it won't do anything, so in the end what's the advantage over React? You can add interactivity without going full SPA with React too after all
1 comments

It's a subtle but huge difference. In React, using JSX means you can create components and mount them on top of the existing elements on the page.

With Vue's HTML templates, the page itself can be the component and everything can become interactive. For example, you can easily output a HTML table from server-side code, then Vue can convert that into a interactive component while using the existing structure and data.

This lets you render the page using existing web frameworks, it's faster because the server puts it together, it's progressive enhancement and works without JS and on slow devices, and Vue can seamlessly add on top with nothing more than a single JS tag and no compilation step.

> For example, you can easily output a HTML table from server-side code, then Vue can convert that into a interactive component while using the existing structure and data.

If you're using vue, you inherently use state or props, and those are handled using {{ myState }} syntax. If you load everything from the backend, it's going to have the actual data in the table. How would you convert the already-rendered HTML to something interactive if the template isn't set up that way?

Fantastic point.

Vue has a bit more flexibility in that regard.

I think you're talking about universal or isomorphic rendering, but each of these allow for it.
No, I'm talking about using hundreds of existing server-side web frameworks that output HTML, not Node/React SSR which is far more limiting.
> In React, using JSX means you can create components and mount them on top of the existing elements on the page.

I am not sure this analysis is entirely correct.

In case of server-side-rendered React pages, React takes the html that arrives from the server and makes it interactive ("hydrates" it, according to the common React community parlance), provided that that DOM generated from that HTML corresponds to the virtual DOM that React generates. It doesn't throw the original DOM away.

This is only if you use SSR and is the opposite of being able to render with any existing web framework.