Features are highly dependent on LocalStorage()

bandhan-majumder

New member
Client side features are highly dependent on the localStorage of browsers. This should not be like that. For example;

I am working on the chat application side. There I have noticed that when I select a chat, the id is stored on the localStorage and highly dependent on it. To test, I cleared the localStorage, and boom, 404 page came. The features is a far thing, the site totally crashed. It should not be like that. We should not trust users on the basis of what they can do but won't do. LocalStorage is cool for stuff like "theme", where it's ok if the client clears the chosen theme. It's ok if suddenly whole site goes on "light" or "dark" mode cause the whole features still works perfectly and does not break anything.

What should be the solution of this?
I was first thinking of persistent storage to solve this issue but persistent storage will not fix this issue. This can be fixed by routes like /chat/:id and so on, so that it's not dependent on the storage anymore


Please comment your thoughts so that we can move forward with a better approach in a reliable way.
 
Last edited:
I completely agree with this.
Relying on localStorage for critical application state (like selected chat IDs) is fragile and unsafe. The moment localStorage is cleared, the app shouldn’t crash or land on a 404.

localStorage is fine for non-critical preferences (theme, language, UI toggles), where losing data doesn’t break functionality. But core flows must never depend on it.
 
Back
Top