Remix.run Logo
Cthulhu_ 2 days ago

Depends on what the commenter means by app state. Anything bookmarkable - like search results - should be in the URL, but "state" should not (I consider things like partially filled in forms, shopping carts, etc to be state).

PaulHoule 2 days ago | parent | next [-]

You have choices, especially all the choices that 1999-style web applications have.

The shopping cart can be kept on the back end and referenced by an id stored in a cookie.

You can keep partially filled out forms in hidden form variables and can send them back in either GET or POST.

Not all requests require all the form data, for instance my RSS reader YOShInOn is HTMX based -- you can see two forms from it here:

https://mastodon.social/@UP8/114887102728039235

in the one at the upper left there is a main form where you can view one item and evaluate it which involves POSTing a form with hidden input fields but above that I can change the judgements of the past five items by just flipping one of the <selects> which needs to only submit the id and the judgement selected in the select. I guess on clicking one of the buttons in the bottom section I could redraw the the bottom section, insert a <select> row at the bottom of the list and the delete the one at the top, but it just redraws the whole form which is OK because I don't have 200k worth of open graph and other meta data in the <head> and endless <script> tags and any CSS other than bootstrap and maybe 5k of my own, which all caches properly.

naasking 2 days ago | parent | prev | next [-]

> Depends on what the commenter means by app state. Anything bookmarkable - like search results - should be in the URL, but "state" should not (I consider things like partially filled in forms, shopping carts, etc to be state).

Yes, shopping cart state should be in the URL in the form of a server-side token under which the cart state is stored. Ditto for partially filled in forms, if that's something your app needs.

All page state should be transitively reachable from the URL used to access that page, just like all state in a function in your favourite programming language should be transitively reachable from the parameters passed into that function, eg. no global variables. The arguments for each are basically the same.

foobarbecue 2 days ago | parent | prev [-]

Presumably you mean search query input, not search results, right?

LeFantome 2 days ago | parent [-]

I think you are saying the same thing. They mean that their wife is trying to send them search results. You are pointing out that the link would contain the search query.

foobarbecue 2 days ago | parent [-]

Not really same thing. If you share the search query, you'll be re-submitting the query at a later time, so the results are likely to be different when the receiver uses that URL. It would be possible (but pretty terrible) to embed the actual search results in the url.

A more reasonable implementation of sharing search results would be to store results on the server and have a storedResults id key in the url.