Top
Best
New

Posted by thm 2 days ago

URLs are state containers(alfy.blog)
488 points | 211 commentspage 4
coolgoose 1 day ago|
This and the lack of proper a hrefs is the biggest pet peeve of mine with a lot of spa's
jFriedensreich 2 days ago||
Hot module replacement masks a lot of annoyances for end users. Yes its more instantaneous than reloading a page and relying on urls for all of the state and I am not advocating hard for abolishing HMR anymore, but it would be nice if we still used way more url state than currently the case. Browsers will also hibernate tabs to varying degrees, server sessions expire all the time, things are not shareable. The only thing that works as users expect is url state. One thing i absolutely hate about ios apps is how every state is lost if i just have the app in the background for a few seconds, this even applies to major apps like youtube, google maps, many email clients etc. Why do we live in this stupid world were things are not getting better, just because someone made things more convenient for developers?

PS: and i curse the day the social media brainwashed marketing freak coined the term "deep link" to mean just a normal link as its supposed to work.

mk12345 2 days ago||
I really like this approach, and think it should be used more!

In a previous experiment, I created a simple webpage which renders media stored in the URL. This way, it's able to store and render images, audio, and even simple webpages and games. URLs can get quite long, so can store quite a bit of data.

https://mkaandorp.github.io/hdd-of-babel/

WilcoKruijer 2 days ago||
nuqs[0] is a great (React) library for managing state inside of the URL.

[0] https://nuqs.dev/

franky47 1 day ago||
Thanks for mentioning it! (I'm the author)
ahmadalfy 2 days ago||
This is the first time I see this, thanks for sharing it
SoftTalker 2 days ago||
Modern browsers have an "open clean link" feature that strips all the query parameters (everything after the '?' character in the URL).

This is because many sites cram the URL full of tracking IDs, and people like to browse without that.

So if you are embedding state in your URL, you probably want to be sure that your application does something sane if the browser strips all of that out.

Ayesh 2 days ago|
> Everything after the '?' character.

It only strips known tracking parameters b(like those utm_ query params). It does not remove all parameters; if that's the case, YouTube video links will stop working.

SoftTalker 2 days ago||
Hm, I didn't know that. Seems very easy to game then, just change your tracking parameter name to one that the browser doesn't strip.
nonethewiser 2 days ago||
>If you need to base64-encode a massive JSON object, the URL probably isn’t the right place for that state.

Why?

I get it if we're talking about a size that flirts with browser limitations. But other than that I see absolutely no problem with this. In fact it makes me think the author is actually underrating the use-case of URL's as state containers.

adolph 2 days ago||
Hanselman famously said “URLs are UI” and he’s absolutely right

A challenge for this is that the URL is the most visible part of an HTTP request but there are many other submerged parts that are not available as UI yet are significant to the http response composition.

Additionally, aside from very basic protocol, domain, and path, the URL is a very not human friendly UI for composing the state.

due-rr 1 day ago||
I use this for my rss reader!

https://rssrdr.com/?rss=raw.githubusercontent.com/Roald87/Ha...

balllpug1 1 day ago||
I disagree in the public URL, as either GPG --quick-generate in coining a counterpoint as a feature of anti-DDOS protocols.

Key is to generate capitol, which is being either a URL or playing hand in ball.

jarofgreen 2 days ago|
Also to consider: bot traffic and SEO.

Depending on which mechanism you use to construct your state URLs they will see them as different pages, so you may end up with a lot of extra traffic and/or odd SEO side effects. For SEO at least there are clear directives you can set that help.

Not saying you shouldn't do this - just things to consider.

Ayesh 2 days ago|
Canonical URLs come to the rescue.
jarofgreen 2 days ago||
Only for SEO - they don't help at all with aggressive AI scraper bots.
More comments...