News for hackers. Stuff that matters.
Re:Htmx and URL State Management by o11c on Tuesday July 29, 2025 @07:54PM (#44729582)
Note that you can store longer state (at least 64K; more not tested) in the fragment (`location.hash`); obviously only the client gets to see this, but it's better than nothing (and JS can send it to the server if really needed).

For parameters the server does need to see, remember that params need not be &-separated kv pairs, it can be arbitrary text. Keys can usually be eliminated and just hard-coded in the web page; this may make short params longer but likely makes long ones shorter.

You absolutely should not restore state based on LocalStorage; that breaks the whole advantage of doing this properly! If I wanted previous state, I would've navigated my history thereto. I hope this isn't as bad as sites that break with multiple open tabs at least ...

Re:Htmx and URL State Management by NegativeLatency on Tuesday July 29, 2025 @08:00PM (#44729635)
I've seem a largish company everyone here knows of, try this and have it fail, because of various weird client things, and also eventually run out of space in the hash. It's a neat hack but I wouldn't rely on it.
Re:Htmx and URL State Management by wredcoll on Tuesday July 29, 2025 @10:16PM (#44730371)
Oh boy, hashbangs are back.

The first one that comes to mind was twitter...

Re:Htmx and URL State Management by mediumsmart on Wednesday July 30, 2025 @01:53AM (#44731206)
I think LinkedIn won the stuffedURLbufferOverflow Olympics back in the day.
Re:Htmx and URL State Management by ashwinsundar on Wednesday July 30, 2025 @01:52AM (#44731203)
They failed as a company?
Re:Htmx and URL State Management by NegativeLatency on Wednesday July 30, 2025 @08:35PM (#44741155)
Still around doing, eh fine. But they abandoned the url hash params with an id that references params on the backend (a mess!)
Re:Htmx and URL State Management by mrits on Tuesday July 29, 2025 @08:34PM (#44729842)
When people start using or buying your software you are going to quickly find out that 64K won't work
Re:Htmx and URL State Management by actionfromafar on Wednesday July 30, 2025 @03:38AM (#44731749)
640K oughta be enough for everyone.