Hacker News new | ask | show | jobs
by londons_explore 1959 days ago
I have built products where user data is stored in the browser...

It inevitably leads to angry users when they hit the "clear cookies" button without realising that will delete all their documents...

It makes it pretty hard to use the browser for any offline use case when the user's expect their data to be persistent, yet don't understand that clearing history/data deletes the data...

Before long you'll be forced to sync the data to a server.

1 comments

There's also a challenge here where browsers will literally just start deleting data from IndexedDB if a user starts running out of space on their hard drive.

I added this statement: "Keep in mind this is a demo app subject to change in the future. You can download your docs at any time." as a warning to anyone who might be using this site with expectations that the data will be persistent.

Ultimately I figure the only solution for a production app is to either do a better job educating users on these issues, or scrap the offline persistence selling point entirely (and just rely on it as a cache).

What did you end up doing with your products?

I ended up syncing the data to the server, and emailing the user with a "magic link" with the decryption/auth keys in.

To begin with I didn't store the encryption key, but too many users lost the original email, so now I also store the user's encryption key, which is lame from a privacy point of view, but for most users is what they expect.

Got it.

Not sure if this was clear here, but when you create an account on this site, the docs do sync to a server automatically. The encryption key is derived from users' passwords (Userbase handles that part). This way if users lose their locally persisted data, so long as they still have their password they're good to go (or vice versa). It's only if they lose both that they lose their data.

But still, given your experience, it does sound like it would be challenging to sell an exclusively offline product using browser storage. Appreciate the insight.