Don't rely on LocalStorage
51–60 of 71 posts
Re: Don't rely on LocalStorage
#52> LocalStorage is popular for web apps because it is lazy No... localStorage is popular because it allows you to persist state without requiring a server, opening up a whole lot of use cases that would normally require a login. With the tradeoff that you can't easily sync between machines and it can be cleared readily. Calling it "lazy" seems bit unnecessarily confrontational. Of all the times I have used localStorag…
LocalStorage serves important use-cases - you mentioned a few - but I‘be seen it used a bunch in web apps, where the user is already logged in, to persist setting. It was easier than adding an API to store a user‘s UI settings/state.
Re: Don't rely on LocalStorage
#53Re: Don't rely on LocalStorage
#54How can they migrate it to server without requiring login? The best part is that you don't need to create any user for playing. Accessing data between devices requires some form of auth.
I would assume almost all daily users of Wordle would consider having to have an account in exchange for persistent, cross-device statistics a worthy trade-off. And presumably a well-designed app could even abuse LocalStorage for anonymous play, and include a mechanism to hand off and save your data, should you wish to, via a login. Social OAuth and passwordless email login (essentially one-time codes) are both prett…
Re: Don't rely on LocalStorage
#55Regarding Wordle specifically, this allowed Josh Wardle to make the app a simple webpage with no backend necessary beyond serving the page itself. Is there something that allows someone like him to do that aside from LocalStorage?
I believe he could have used Cookies instead of LocalStorage. The data he's keeping seems simple enough. It has the same issues the author is talking about, but it should work.
Re: Don't rely on LocalStorage
#56"If you want your stats proper and orderly, play the game only from your phone, buddy."
Re: Don't rely on LocalStorage
#57> Ultimately, people should have control of their data, and they should have access to their data from all of their devices. Whether that is running their own or renting someone else's, that ultimately means the correct place to store web app data is on a server. Hrm. But I don't have control of my data on a server. The person running the server does. There is currently no good way to satisfy both of these conditions…
I specifically refer to self-hosting here, which does satisfy both of those conditions. (There is arguably still a lot of stress to making self-hosting a better experience for non-technical users, and unfortunately large tech companies are very motivated to maintain a paradigm opposed to self-hosting.) But I also do not feel LocalStorage is really a good way to ensure you have control of your data: It's very unlikely…
There's nothing in this critique that doesn't also apply to hosted (server-based) storage.
If anything, it's harder to do those things with servers, because (a) if you the user are truly paranoid, it's trivial to throw a switch and make sure that no data is getting out—by shutting off your network connection entirely, whereas with server-based storage for user data the user has to do some form of whitelisting or blacklisting, and (b) it's pretty straightforward to get all your data at any given time, esp. since the localStorage API is well-defined, whereas if the application author had started with a server-based approach, it probably would have been a server under their control and not yours, which means your best shot involves either intercepting all communications from the beginning (instead of after the fact, once you realize you're interested in it) or doing the legwork to figure out the protocol and issue the appropriate request(s) to get all of it (rather than just a view), if that's even possible.
Overall, I don't think this post makes a very forceful argument that localStorage is bad, only that there might be a better experience for users if all the following conditions hold true:
1. they're playing across multiple devices
2. they're willing to take the time to connect to remote storage
3. the developer behind the app is sympathetic to the cause of data portability and/or user-controlled data, and is therefore willing to implement the necessary integration to enable #2
Failing that, a world where developers are defaulting to localStorage is still a much better state of affairs than what's typical of application authors today.
Re: Don't rely on LocalStorage
#58Sure you won't be able to see all of your friend's stats in one nice looking UI, but I doubt that has bothered anyone tremendously. If anything, what you perceive to be crutch actually encourages people to share their result 1-1 with their friends in whatever chat apps they please. That to me, is a feature, not a bug.
Re: Don't rely on LocalStorage
#59How can they migrate it to server without requiring login? The best part is that you don't need to create any user for playing. Accessing data between devices requires some form of auth.
Many auth providers allow anonymous auth, which creates a UID that can be used to store and secure data. Only later the customer can link that account with another identity provider (e.g. socail, email/password). This gives the low-friction benefits of local storage and the flexibility of cloud storage.
Re: Don't rely on LocalStorage
#60How can they migrate it to server without requiring login? The best part is that you don't need to create any user for playing. Accessing data between devices requires some form of auth.
I would assume almost all daily users of Wordle would consider having to have an account in exchange for persistent, cross-device statistics a worthy trade-off. And presumably a well-designed app could even abuse LocalStorage for anonymous play, and include a mechanism to hand off and save your data, should you wish to, via a login. Social OAuth and passwordless email login (essentially one-time codes) are both prett…
Not for me, absolute deal-breaker. My fingers would find ctrl-w before the "Log in with Facebook!" modal finishes rendering.