Forum Academy Marketplace Showcase Pricing Features

Use localStorage to store data on your users browser indefinitely

I was looking for a way to store users’ session/progress data without relying on URL params and custom states, initially, I was just gonna store that data in the database, but then I found localStorage. Basically, you can store up to 5MB of key-value pairs on your user’s browsers, and the data lives on even upon page reload/redirect.

Using the toolbox plugin, you can save data to the users localStorage via the following script:
localStorage.setItem("key","value");

And then access it using the JavaScriptToBubble Element that comes with toolbox + an HTML element:

setTimeout(function() {
bubble_fn_a(localStorage.getItem(“Color”));
},1000);

Here is my full writeup with step-by-step instructions:
https://medium.com/@bek_akhmedov/the-power-of-localstorage-for-bubble-io-development-12afc87c6ec9

Let me know if you get stuck behind a paywall and il just copy and paste the whole thing in here.

Bek

4 Likes