News for hackers. Stuff that matters.
Re:How to store your app's entire state in the url by escot on Monday January 09, 2023 @12:20PM (#34312828)
Hey all, I made this post to show a technique that I'm using in my keyboard-centric flowchart editor [0]. I really love urls, and the power that they hold, and would love to see more apps implement little hacks like this.

Also, another shout out to mermaidjs and flowchart.fun for also implementing similar url-based sharing.

[0] https://www.knotend.com

Re:How to store your app's entire state in the url by tlarkworthy on Monday January 09, 2023 @12:25PM (#34312903)
There is a size limit though that quickly gets exhausted if you are storing text (2000 chars)
Re:How to store your app's entire state in the url by rmetzler on Monday January 09, 2023 @12:59PM (#34313467)
This is the right answer here. The solution works until it doesn’t. Browser URLs are limited in real life. So when the state grows it will break sooner or later. Of course it depends on the usecase.
Re:How to store your app's entire state in the url by tonerow on Monday January 09, 2023 @01:01PM (#34313519)
(maker of flowchart.fun here) This is technically true but it's a little more nuanced. The 2048 character limit comes from Internet Explorer. There's a great answer on SO https://stackoverflow.com/a/417184/903980

Still on FF I opted to use LZ Compression (pretty sure many other sites do this as well) to get the number of characters down

Re:How to store your app's entire state in the url by tlarkworthy on Monday January 09, 2023 @02:09PM (#34314558)
I have done this myself and various tools e.g. slack, Twitter will truncate long urls. Eventually it will break somewhere, not just in the browser. If your tool has a hard limit on information content it's ok, but that does not seem to be the case here.
Re:How to store your app's entire state in the url by escot on Monday January 09, 2023 @01:07PM (#34313613)
You're right, its a limitation. Knotend also supports upload/download of a .knotend file to get around this.
Re:How to store your app's entire state in the url by __MatrixMan__ on Monday January 09, 2023 @03:19PM (#34315422)
Store the content in ipfs and just put the hash in the URL?

I haven't used https://github.com/ipfs/js-ipfs in this capacity but I'm under the impression that that's moving bits around like that is more or less its purpose.

Although I suppose this puts a burden on the URL-creator to pin the content until the URL-clicker doesn't need it anymore, which is not how URLs are supposed to work.

Re:How to store your app's entire state in the url by tonerow on Monday January 09, 2023 @01:03PM (#34313544)
Love the app!
Re:How to store your app's entire state in the url by escot on Monday January 09, 2023 @01:16PM (#34313787)
Thanks!
Re:How to store your app's entire state in the url by bytesandbots on Tuesday January 10, 2023 @10:59AM (#34326832)
If the schema is fixed, using proto buffers will greatly reduce the length required.