Search code examples
javascriptstoragefile-uri

Any alternative for JS storage under file protocol?


I am developing a HTML5 game, and would like to share it with file base. So my friends can play it with a local html file (file://xxx.html).

However, most of the storage are based on the domain, such as localStorage. I would like to know if there is any alternative to persist the game-progress-save under file-protocol?

I searched that windows.name may be the solution, but it can not store data after closing the browser. Javascript/HTML Storage Options Under File Protocol (file://)

I also found the FileSystem API (Window.requestFileSystem), but seems only Chrome has implemented it.

Any suggestion?


Solution

  • You can:

    • Bundle it by using Cordova or Electron
    • Use Node.js + lite-server
    • Use some free hosting service, my prefered solution would be Firebase as you would get a free yourGame.web.app domain, certificate and storage. You could set it up in less than an hour. To be honest, this is what I would do as it would be easiest for your friends to access the game too.