Hacker News new | ask | show | jobs
by schemescape 978 days ago
One issue with publishing a browser-based game that this article glosses over is: managing save data.

The browser provides Local Storage, but that isn't reliable as a "source of truth" since browsers (mostly on iOS, I think) may delete the data periodically (thanks, iOS, for deleting my Wordle history!) or when clearing browser history. Aside: the worst situation is when publishing on itch.io and playing on an iPad--your data appears to get saved to Local Storage but is actually wiped immediately to prevent cross-site tracking (itch.io hosts HTML5 games in a frame with a different domain).

Publishing on Steam, on the other hand, gives you durable file system storage and you can add cross-device syncing via Steam Cloud very easily. I'm holding out hope that something like remoteStorage will eventually catch on for browsers, but for now I don't really see a convenient solution.

If anyone has ideas for managing save data in a browser game that don't involve hosting user data myself (and dealing with account recovery, GDPR, etc.), let me know!

5 comments

Yes, the FileSystem API works well.

It's getting some improvements soon (at least from Chrome), currently requires renewing approval on every page load. https://bugs.chromium.org/p/chromium/issues/detail?id=101153...

It works well for my use case. If you want to see it in action: https://web.zquestclassic.com

The problem of course is not all browsers support. As a backup, I use either indexdb or local storage.

What about calling navigator.storage.persist() to prompt the user to allow persistent storage?

Wow, thanks for the warning about that itch.io problem. It's discussed here: https://itch.io/t/2636350/localstorage-doesnt-work-for-html5... and behaviour of Safari's default-on "Prevent Cross-site Tracking" here: https://stackoverflow.com/questions/63922558/safari-localsto...

So this is happening because itch.io hosts the game on a CDN subdomain such as v6p9d9t4.ssl.hwcdn.net which may change at any time? If it doesn't change, it sounds to me like there should be no problem, but I suspect I misunderstand. And sounds like it's Safari, not just iOS?

I'm about to start letting users export their games to html5, almost all of which will end up on itch.io, so really need to solve this too.

I had never heard of navigator.storage.persist(). I will give it a try, thanks!
I'm running up against this pain in a hobby project. The best options I've come up with so far are:

* WebRTC and NAT traversal to let the user sync files (complicated but viable for my use case but pretty dumb for gaming). * Cloud storage and anonymized social logins with E2E encryption (cue key management horror stories) * Download a file on exit, upload on resume (terrible UX)

A bit like the 16-bit game consoles : tell your user that saving the game involves them saving a string of characters, in base58 for instance ?
FF only support the origin private interface for the FSAPI, which has all the same problems re: persistence as local storage