news.volyx.in

URLs are state containers (alfy.blog)

512 points by thm · 265 days ago · 213 comments on HN

Article summary

The article discusses the importance of URLs as state containers in web applications, highlighting their role in storing and sharing application state. It provides examples of how URLs can be used to encode state, such as query parameters and anchor fragments, and argues that this approach can make web applications more resilient and predictable. The article also explores best practices for URL state management, including using defaults, debouncing URL changes, and avoiding pollution of URLs with default values. By treating URLs as first-class state containers, developers can create more user-friendly and shareable web applications.

Main themes

  • URLs as state containers
  • Web application architecture
  • State management
  • Shareability and bookmarkability
  • Web development best practices

What commenters say

  • Using URLs to store state can be a powerful approach to web application development, but it requires careful consideration of the trade-offs involved.
  • The approach of storing state in URLs can be limiting when it comes to evolving system design and refactoring state structure.
  • Some argue that storing state in URLs is not a good practice, as it can lead to cluttered and hard-to-read URLs, and that other approaches, such as using session cookies, may be more effective.
  • Others argue that URLs are not just locators, but can also be used to represent state, and that this approach can be beneficial for user experience and shareability.
  • The use of URLs to store state is related to the concept of HATEOAS, but the two are not identical, and HATEOAS is more focused on defining data formats and hypermedia controls.
  • There are potential drawbacks to using URLs to store state, such as the difficulty of handling multiple tabs and the back button, and the need for inter-tab mechanisms to resolve duplicate IDs.
  • Some developers argue that storing state in URLs can be a good approach for simple applications, but may not be suitable for more complex applications with large amounts of state.
  • The design of URLs and their role in storing state can have significant implications for user experience, shareability, and web application architecture.