Saving LiveView UI related state into browser is a bad idea?

Hi I just read Saving and Restoring LiveView State · The Phoenix Files and could someone explain why this is bad idea?

It may even include UI centric things like which tab is active or if a region is expanded. It doesn’t make sense to store state like that.
Don’t store UI related state.

If WebSocket gets disconnected and reconnected state needs to be restored then what is better way than storing active tab or expanded views into browser?

1 Like

You should store such state with query params, then the state of a view is deterministic. Reconnect and you will get same result. Achieved using push patch :slight_smile:

5 Likes

Great idea! I’m so old school that I didn’t remember that we can now change query parameters without refreshing the page.