Live data from Hacker News

URL-Driven State in HTMX

lorenstew.art

111–120 of 188 posts

Re: URL-Driven State in HTMX

#112

> SEO is built in since search engines can crawl every state combination. This isn't always a plus - bots can find a very large number of pages to crawl and swamp your server with traffic. Maybe they would get stuck on all the combinations of listing page filters and miss the important pages. Not saying the conclusion is wrong - just something to consider.

That's why you can give guidance to crawlers using sitemaps.

Which, just like robots.txt, worked decently well until the AI bot crawlers overwhelmed all else.

Re: URL-Driven State in HTMX

#114

I think people are now ready for php. I bet it will be reinvented on top of nodejs.

I feel revindicated for staying with ASP.NET and JavaEE/Spring all these years.

Next.js is kind of bareable, as it uses the same approach, going back to the roots of web development, it is almost as doing JSPs all over again.

Re: URL-Driven State in HTMX

#115
post #97

I think people are now ready for php. I bet it will be reinvented on top of nodejs.

As a long time PHP developer, it never fails to amuse (amaze?) me the lengths people go to in order to get the things the browser will give you for free.

php is great but I’m surprised by how people are not discussing htmx.

It’s a chance to start all over yet again! Come on- we’re all up for that, we do it every few months!

Re: URL-Driven State in HTMX

#116
post #79

I think people are now ready for php. I bet it will be reinvented on top of nodejs.

At some point I hope it becomes obvious that well-engineered SSR webapps on a modern internet connection are indistinguishable from a purely client side experience. We used this exact same technology over dialup modems and it worked well enough to get us to this point. Being able to click a button and experience 0ms navigation is not something any customer has ever brought to my attention. It also doesn't help much i…

> At some point I hope it becomes obvious that well-engineered SSR webapps on a modern internet connection are indistinguishable from a purely client side experience.

I dunno; other than the fact that there are some webapps that really are better done mostly client-side with routine JSON hydration (webmail, for example, or maps), my recent experimentation with making the backend serve only static files (html, css, etc) and dynamic data (JSON) turned out a lot better than a backend that generates HTML pages using templates.

Especially when I want to add MCP capabilities to a system, it becomes almost trivial in my framework, because the backend endpoints that serve dynamic data serve all the dynamic data as JSON. The backend really is nicer to work with than one that generates HTML.

I'm sure in a lot of cases, it's the f/end frameworks that leave a bad taste in your mouth, and truth be told, I don't really have an answer for that other than looking into creating a framework for front-end to replace the spaghetti-pattern that most front-ends have.

I'm not even sure if it is possible to have non-spaghetti logic in the front-end anymore - surely a framework that did that would have been adopted en-masse by now?

Re: URL-Driven State in HTMX

#118
post #109

Earlier quoted context omitted.

What about a feature like query completion?

The query completion can also be SSR. The example below is HTMX for Active Search, but the principle is the same: https://htmx.org/examples/active-search/

I suppose that is a rather neat way to do it.

Re: URL-Driven State in HTMX

#119

This is a classic pattern of web applications from the 1990s. Works amazingly well even w/o HTMX

One of the legitimate grievances of SPAs is that they made this pattern less obvious.

More like we have a whole generation educated in bootcamps that think they need SPAs for doing anything.

Re: URL-Driven State in HTMX

#120

Earlier quoted context omitted.

> The same thing should happen that happens with Rails/Django and friends: nothing So you can never make any breaking change to your api whatsoever? Or, in practice, you don't care and let users deal with app crashes and invalid state? Yep, welcome to the frontend-world.

why do you think that this must happen on the front-end? you can make a breaking change and when the user submits an invalid state a) serve an error page, leaving that to the backend (at some point the backend must validate anyway) b) serve the regular front-end and react to the invalid state with error messages. there are libraries like zod that should make your job easier.

> why do you think that this must happen on the front-end?

It must happen on both frontend and backend, because it's about their communication with each other. So that includes frontend.

> a) serve an error page, leaving that to the backend (at some point the backend must validate anyway)

> b) serve the regular front-end and react to the invalid state with error messages. there are libraries like zod that should make your job easier.

I mean, that is exactly what makes me so frustrated! Sorry, you are just giving a good example of what I'm complaining about. Both of those solutions are sub-optimal.

Here is how I'd implement that by hand if I would write something like nextjs/django:

1.) The frontend always sends a version in each of it's request (in the payload, the header, wherever)

2.) The backend compares that version against what it is expecting and compatible with. If it detects an outdated/incompatible version then there are two options: it is somehow possible to automatically fix it. For example because the used protocol has some mechanism and the developer uses that (such as default values for missing values) or because the developer has manually provided a migration for old versions.

3.) If it can be fixed, all good. If not, the backend sends a message back, saying that the request cannot be processed because the version is too old. The user can then decide to e.g. save their state elsewhere and reload, or just reload. Or do something completely different.

4.) Bonus: while we are at it, why don't have that fronted send regular requests to backend and ask if the version is still up-to-date (especially if it's the type of user that has their browser tab open forever). That would help to prevent data loss or other problems before they even occur, because the user gets an info and can refresh early.

Why should I implement all of that myself over and over again? Are you guys really thinking that this should not be handled, or at least made very easy, by typical weblibs/frontends such as nextss or django?

Post reply on HN