DEV Community


Deno v1.10 has added support for localStorage. What do you think would be a good use case for this feature?

Web developer from Venezuela. I like solving problems. Currently trying to improve my communication skills
・1 min read

Here are some of the details: Support for Web Storage API

My first thought was some sort caching mechanism. Like, if I have a script that fetches data from the internets or takes a very long time to produce some piece of data, I could use localStorage to save that data. Then if someone executes the script again in a very short amount of time, I could give them the cache in localStorage.

My second thought was some CRUD stuff. Something like zoxide came to mind. I could make (and I actually did) a glorified CRUD utility that stores the path to the most frecuently visited directories, and then query that and use the result to "jump" quickly to that location.

Beyond that I'm having a hard time imagining how this could be useful. I'm not saying it's useless, having a tiny database can be handy. I just don't know when to use it.

Discussion (4)

johncarroll profile image
John Carroll • Edited

As one example. A while ago I made a simple discord bot that my friends could interact with. To save state, the bot wrote JSON to a file on my computer. Using localstorage would be a cleaner approach to this same task (especially if I distributed this module to others via something like npm). I expect that there are many uses for this feature. Being able to save data without needing filesystem access is helpful.

vonheikemen profile image
Heiker Author • Edited

I haven't created a bot before but I have used JSON files to store data. Avoiding that boilerplate is certainly a win.

ivanjeremic profile image
Ivan Jeremic

IndexedDB would be better

vonheikemen profile image
Heiker Author

let's hope they can implement that one too.