News for hackers. Stuff that matters.
Re:Htmx, Raku and Pico CSS by shortrounddev2 on Monday September 09, 2024 @09:31AM (#41488362)
I think most people choose SPAs because they also maintain the frontend state of a an application. If you're just serving templated html from a backend, you're probably also doing vanilla javascript which is it's own kind of hell. How do you manage the transition between one view and another on the same page? How do you pass state between two pages? I think webcomponents solve some of this but there's a lot of react developers out there who don't have the requisite software engineering skills to handle this
Re:Htmx, Raku and Pico CSS by consteval on Monday September 09, 2024 @01:33PM (#41491076)
> How do you manage the transition between one view and another on the same page?

HTMX solves this, and it's mostly automatic. You get some nice transitions.

> How do you pass state between two pages?

You don't. You submit some data to the server, it generates HTML dynamically, you replace HTML on the frontend or redirect all together, you're done. The state is on the server.

Re:Htmx, Raku and Pico CSS by shortrounddev2 on Tuesday September 10, 2024 @07:56AM (#41499857)
So then you need some kind of state management on the server?
Re:Htmx, Raku and Pico CSS by consteval on Tuesday September 10, 2024 @01:20PM (#41503209)
> So then you need some kind of state management on the server

Yes. You might call this an application, lol. You will require this no matter what, unless you have a fully client-side application. Like photoshop or something.

Re:Htmx, Raku and Pico CSS by JodieBenitez on Monday September 09, 2024 @01:35PM (#41491104)
> If you're just serving templated html from a backend, you're probably also doing vanilla javascript which is it's own kind of hell.

How so ? Vanilla JS has never been easier and more powerful.

> How do you pass state between two pages?

Why is it even considered to be a problem ? This is basic stuff. All web frameworks since the 90s have had this concept of sessions where you can store data that will be available across pages.

Re:Htmx, Raku and Pico CSS by shortrounddev2 on Tuesday September 10, 2024 @07:57AM (#41499864)
Vanilla js is unstructured. It's very easy to write spaghetti code with vanilla js.

Sessions are a kind of global state. I mean temporary state, like when filling out a form and moving from one page to the other, but without submitting the results until the end.

Re:Htmx, Raku and Pico CSS by JodieBenitez on Tuesday September 10, 2024 @10:48AM (#41501352)
> Vanilla js is unstructured.

Functions, classes, modules... everything is available to organize code. The mess some programmers make can be unstructured, but that's the case with any paradigm and yes, we've seen that with "modern" JS frameworks too. Spaghetti mess, lasagna mess, components mess or whatever pasta mess.

> I mean temporary state

What is the problem here ? It's as temporary as you need it to be.

Re:Htmx, Raku and Pico CSS by shortrounddev2 on Tuesday September 10, 2024 @11:21AM (#41501682)
Temporary state does not need need to be sent to the server, it can be managed in localstorage