Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extend localStorage across devices (without DB)

Goal: extend my already implemented localStorage in my app, to be well, non local I guess.


I like the implementation of saving simple user settings with local storage API. I have this working for my needs in a web app, but the only problem is it's local to that machine / browser being used/saved. I do not have access to a classic MySQL style table for this. I would like to extend or adapt my local storage to carry over to other browsers; or store my user settings in user JS objects and JS object properties.

  • I like the idea of just creating JSON or JavaScript objects with each user, whenever there is a new user, take the name, create an object or object[key] with the name, and have the field properties default variables at first, and variables become populated and or overridden when the user saves them.
  • Or if the above is frowned upon; would like to keep my localstorage implementation as it works so well and find a plugin/library/extension of some sort that allows me to also save this and re-render in different locations; this has gotten to be thought of before. Although I would love to keep it client side; I am open to a node.js solution as well as python solution, a simple dataframe of sorts should work enough.
  • What about generating a file with my localStorage data? Perhaps a .csv file (this is non sensitive data) and have it update as my localStorage does?
like image 895
fred randall Avatar asked Feb 12 '20 00:02

fred randall


2 Answers

What about using sqlite?

Just one file on your server like csv. Sending a http request To update it using SQL statement by knex or something like that after updating the localstorage on the client-side.

At least it is better than cvs I think because you can define several tables, which is more scalable, and more efficient, you know, it is a database.

like image 73
kobako Avatar answered Sep 28 '22 10:09

kobako


Instead of using localstorage, store your user's settings in the InterPlanetary File System (IPFS) https://ipfs.io/

Basically, you would put their setting is a data format like JSON and then write it to file and push it to IPFS.

You will need a way to identify which data goes to which user. Maybe you could use a hash of the username and password to name your files or something like that. Then your user's would always be able to access their content on any device (as long as they didn't forget their password).

like image 34
Michael Babcock Avatar answered Sep 28 '22 09:09

Michael Babcock