What are some easy, lightweight ways to write and save small quantities of data for a dirt simple web app?

I literally just need to save/write one number. I'm writing a counter app and I want to be able to save the value of the counter whenever I close the app. I have no plans to distribute this app so I'm perfectly fine with storing the data on my machine. I've learned a little bit of mongoDB but it's not lightweight enough for my purposes. Can I just read/write from a JSON file? Is there something better?

1 answer

  • answered 2019-10-15 17:39 Nicolas

    You could save it into the Html5 localstorage.

    window.localStorage.setItem('counter', yourCounterVariable).

    And then retreive it using

    window.localStorage.getItem('counter')

    This information will be saved localy by the browser and will be available until the user clear it.