News for hackers. Stuff that matters.
Re:Using React, Redux and SSR to acommodate users without Ja... by WrtCdEvrydy on Sunday June 07, 2020 @01:05AM (#23444902)
SSR gets you most of the way there... your code just has to respect the URL as the 'global state' and turning any user input into link-based data (ie, click this, provide a URL, process the URL).
Re:Using React, Redux and SSR to acommodate users without Ja... by unityByFreedom on Sunday June 07, 2020 @01:31AM (#23445013)
> turning any user input into link-based data

I wish all javascript websites would do this too. Unlinkable stuff grinds my gears =)

Re:Using React, Redux and SSR to acommodate users without Ja... by ohlookabird on Sunday June 07, 2020 @03:12AM (#23445422)
> URL as the 'global state'

Are there still (browser) limits on how long such a URL can be? Would it e.g. be possible to store a text of 50.000 words in the URL alone?

Re:Using React, Redux and SSR to acommodate users without Ja... by londons_explore on Sunday June 07, 2020 @03:32AM (#23445497)
Well you could always store the state in a database serverside and give the client some token to look up the state...
Re:Using React, Redux and SSR to acommodate users without Ja... by wereHamster on Sunday June 07, 2020 @08:01AM (#23446767)
Ah the good old JSESSIONID…
Re:Using React, Redux and SSR to acommodate users without Ja... by zodiakzz on Sunday June 07, 2020 @04:54AM (#23445874)
You can submit a form on click with an HTTP POST method - without any JavaScript. Doesn't make sense to cram so much data in a URL.
Re:Using React, Redux and SSR to acommodate users without Ja... by csiegert on Sunday June 07, 2020 @09:43AM (#23447269)
But then you don’t keep the state in the URL.
Re:Using React, Redux and SSR to acommodate users without Ja... by city41 on Sunday June 07, 2020 @11:17AM (#23447964)
Modern browsers support very long URLs. Chrome supports URLs up to 2mb for example. Probably makes sense to think about the impact on users before using such long URLs, I have found it confuses people, and can also make sharing things on social media impossible.
Re:Using React, Redux and SSR to acommodate users without Ja... by WrtCdEvrydy on Sunday June 07, 2020 @12:14PM (#23448379)
You wouldn't cram the entire state into it, but you would cram enough data to be able to recreate your state (ie, an API-backed application might store the parameters required to make API calls)
Re:Using React, Redux and SSR to acommodate users without Ja... by danielskogly on Sunday June 07, 2020 @10:03AM (#23447411)
That can definitively work for some applications!

My goal with this post and demo was to outline a general strategy that could be employed in both small and large applications. For some cases, you could implement the server-side dispatching of actions as listening on GET-requests, but you would potentially be polluting the browser history more than necessary, and be capped to ~2k characters (varies in browsers) for actions (which for many cases should suffice).

I imagine that keeping all _state_ in the URL, while it can work for some small applications, might not scale sufficiently to be a general approach to the problem, nor have the kind of persistence usually found in eg. applications with login, where a user might expect to be able to authenticate and continue where they left off.