news.volyx.in

How to store your app's entire state in the url (scottantipa.com)

640 points by escot · 1335 days ago · 395 comments on HN

Article summary

The article discusses a technique for storing an application's entire state in a URL, allowing users to share and access their data without needing to sign in or store it on a server. This is achieved by encoding the application state as a Base64 string in the URL's hashmark. The author uses this approach in their flowchart editor, Knotend, to enable easy sharing and collaboration. The technique also provides a simple undo/redo functionality using the browser's history stack.

Main themes

  • URL-based state storage
  • Application state encoding
  • Data sharing and collaboration
  • Browser limitations and usability
  • Alternative storage approaches
  • Data compression and optimization
  • Security and abuse concerns
  • Use case suitability and limitations

What commenters say

  • Using the URL's hashmark to store application state is a viable approach, but it has limitations, such as potential truncation by browsers or chat apps.
  • Storing large amounts of data in the URL can lead to usability issues, such as extremely long URLs that are difficult to share or copy.
  • Alternative approaches, such as using local storage or a backend server, may be more suitable for certain use cases, especially when dealing with large amounts of data.
  • The technique can be optimized by using compression and encoding to reduce the size of the URL.
  • Some commenters argue that using the URL's hashmark is not suitable for storing large amounts of data and that other approaches, such as local storage, should be used instead.
  • Others suggest that using a combination of approaches, such as storing a hash sum in the URL and the actual state in a JavaScript object, can help mitigate the limitations of the technique.
  • There are concerns about the potential abuse of storage if the data is stored on a CDN or other centralized server.
  • The approach can be useful for certain use cases, such as sharing flowcharts or other visualizations, but may not be suitable for more complex applications or larger datasets.