WebReflection / uhtml

A micro HTML/SVG render
MIT License
923 stars 38 forks source link

What is the suggested approach for using uhtml on both the server and client? #139

Open nickchomey opened 1 month ago

nickchomey commented 1 month ago

I see that the uhtml-ssr and ucontent libraries are available for SSR templating, but they seem to have not received any updates in 2 and 4 years, respectively. That doesn't mean that they don't work, but I'm curious how they compare to uhtml which has been actively developed since then? Also should we be using uhtml-ssr or ucontent for SSR templating?

Moreover, are there any special considerations to take into account if we want to use one of those for SSR and use (ideally) the exact same code/templates with uhtml in the browser?

Thanks!

WebReflection commented 1 month ago

Currently uhtml/ssr is the new way to deliver server templates but it cannot compete in raw performance with uhtml-ssr because:

Arguably, ucontent for SSR only is probably the best way to go but if you are looking for 99% interop (events and hydration are still missing) uhtml/ssr would be my pick.

I promise I won't create any other library and all of these helped me to reach stability and maturity with uhtml itself but there's something missing for the BE story that one day I'll fix ... I don't have capacity these days though and free time to work on this is unfortunately too little.

nickchomey commented 1 month ago

Thanks very much for confirming that all of those are valid options (and also for making me aware of uhtml/ssr)! I'll give them a try to see which will suit my needs best.

nickchomey commented 2 weeks ago

Apologies if I should ask this elsewhere, but it seems relevant enough here:

What I'd now like to do is

  1. fetch some html pages
  2. parse them
  3. Extract some particular nodes and replace parts of them with uhtml template literal placeholders
  4. Save those as js scripta that can then be rendered later both SSR and in the browser

I'm curious which of your libraries you would suggest for this?

Is Linkedom the most appropriate for the dom parsing, extraction and manipulation? And then one of the above options for the actual SSR rendering of the templates? And then normal uhtml in the browser, with the same js script templates?

Thanks!