Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: What's your favourite way to store/host <1KB of state on the Web?
2 points by Waterluvian on July 12, 2023 | hide | past | favorite | 5 comments
I do a lot of web-based hobby/fun apps/games for fun. An issue I keep running into is preserving basic state (eg. progress, save data, etc.) It's always tiny: <1KB. I could use `localstorage` but I want to share that state across devices.

Because these are toys, I don't need security, backups, scale, or size. Which makes almost any choice I professionally know about feel like overkill. I do not want to have to worry about or maintain a web server.

I feel like I am looking for a service something like this:

1. Make an account and receive a token.

2. Embed the token in my game.

3. Use the token to make GET and POST to the service.

4. Don't abuse it or my token gets rescinded and now nobody can access their high scores or whatnot.



To glibly answer your question: favorite way? In the "usercloud" (as a cookie).

But more in depth, it's a good question!

You could get innovative and use localstorage combined with WebRTC to create a p2p storage "mesh". :)

Honestly tho I would use GitHub gists. They have an API. There's a token you can get. You could use whatever storage format you want (JSON anyone? Blah, why not just use malbolge).

Or if you're doing gists, why not go the whole nine gits? Depending on what your game runs on, you could just use git, to a shared repository, on GitHub.


A gist is a great idea. The one issue, I think, is that I cannot expect users to have a GH account, and I'm not sure it's sensible to make a GH account and embed a Token in the app.

That's the rub, I think. Any sensible person would scream, "SECURITY HOLE!" but for my use case, it's not an issue. Just some high scores for a game that like 100 people might play in its lifetime, or whatnot.


Encode your game state to the URL itself and tell the user to bookmark that URL. User can then use browser sync, email or whatever to sync the bookmark to another computer to continue where they left off. No services, no tokens, no sharing data to some random company or person.


A URL is about 2000 characters max, so this definitely works. It's a more portable than localstorage given they can just handle the URL themselves.

This doesn't cover collective access. Eg. high scores, though. I'm still thinking on that one. I think it's going to be impossible to find because of security implications. Services are either going to not want to make it work, or require accounts.


I used a free redis instance. There are all sorts of free database and storage services out there. Cloudflare has some really cool free stuff.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: