<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bek Akhmedov on Medium]]></title>
        <description><![CDATA[Stories by Bek Akhmedov on Medium]]></description>
        <link>https://medium.com/@bek_akhmedov?source=rss-10a1a29b8839------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AA7BHK_5Y3pZjvv77kdnsQ.jpeg</url>
            <title>Stories by Bek Akhmedov on Medium</title>
            <link>https://medium.com/@bek_akhmedov?source=rss-10a1a29b8839------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 25 Nov 2026 02:00:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bek_akhmedov/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Power of localStorage for Bubble.io development]]></title>
            <link>https://medium.com/@bek_akhmedov/the-power-of-localstorage-for-bubble-io-development-12afc87c6ec9?source=rss-10a1a29b8839------2</link>
            <guid isPermaLink="false">https://medium.com/p/12afc87c6ec9</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[full-stack]]></category>
            <category><![CDATA[bubble]]></category>
            <category><![CDATA[no-code]]></category>
            <dc:creator><![CDATA[Bek Akhmedov]]></dc:creator>
            <pubDate>Sat, 23 Jul 2022 17:19:16 GMT</pubDate>
            <atom:updated>2024-01-25T19:15:05.791Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>TL;DR: You can use localStorage to store data on the user&#39;s browser indefinitely.</strong></h4><h3>Intro</h3><p>If you‘ve ever built an app in Bubble.io, you know the awkward moment where you have no idea where to store a certain piece of temporary data. Do you use custom states? Maybe URL params? Cookies? How about just saving it in the database itself? UGHHHH.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jysQtLT39pc7b0kpbG_oKw.png" /></figure><p>Fear not, as in all things bubble, a little bit of JavaScript is always the solution!</p><h3>What is localStorage?</h3><p>localStorage is a property of the window interface that allows you to store and access key-value pairs across browser sessions. Think of it as a mini SQL database inside your user&#39;s browsers, with a lofty 5MB storage cap. For my bubble developer friends, that means you can use it as a custom state that doesn&#39;t disappear upon page reload. If you want to read it directly from the horse&#39;s mouth, here you go:</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage">Window: localStorage property - Web APIs | MDN</a></p><h3>Where does it live?</h3><p>Chrome Dev Tools → Application → Storage</p><p>Each domain has its own Local Storage, even at the HTTP vs HTTPS level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*nFjxRPJnd3hCB4p-FLoKyg.png" /><figcaption>My local storage for codebridged.com (hey that&#39;s me!) consists of two keys: ‘tech’ and ‘bubble_debugger_situation’</figcaption></figure><h3>See it in action:</h3><p>Here is a very basic example, I created a UI in Bubble that lets you create and edit key-value pairs. There is a repeating group below the input fields that shows all of your key-value pairs for my domain. Refresh, navigate, or exit the page and reopen the website, and the data is still there! You can also open an incognito session and it will be a clean sleight.</p><p>For funsies, add a hex code to the key ‘Color’ and you will see a shape element pop up with your color.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*ywGqHwUwajdvVCRhKrZ6Uw.gif" /></figure><p>Try it out yourself: <a href="https://codebridged.com/example/localstorage">https://codebridged.com/example/localstorage</a></p><h3>Building it in Bubble.io</h3><p>The above example is demonstrating three capabilities:</p><ul><li>Creating/editing a key-value pair (Input fields)</li><li>Accessing all of your user’s key-value pairs on your domain (Repeating Group)</li><li>Displaying content based on the data (Color Shape)</li></ul><p>I will walk you through how I built the above process in Bubble. If you follow these steps, you will be able to create, edit and access localStorage values for your users on your domain.</p><p>You will need the Toolbox plugin (it’s free). I am sure there are plugins in the bubble ecosystem to access localStorage, but I prefer to just build it myself.</p><h4>Cap 1: Creating/Editing Key-Value Pairs</h4><p><strong>Step 1:</strong> Put 2 input fields and a button.</p><p><strong>Step 2: </strong>Create a workflow that runs the following JavaScript upon button click: localStorage.setItem(“Input keys value”, “Input values value”);</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*A4OTRYpXtzEU-dShvjLGEQ.png" /></figure><p>That’s it! That workflow will take your inputs and create a key-value pair in your users’ localStorage. If a key exists, it will update it. Simple as that. You will need to refresh the page for the changes to take effect, so add that as well.</p><h4>Cap 2: Accessing all of your users’ key-value pairs on your domain</h4><p><strong>Step 1:</strong> The Toolbox plugin comes with an element called “Javascript to Bubble”, create one of those elements. Here is what mine looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*sRwfCwpApHE-jcjjpywF0w.png" /><figcaption>We can run a JavaScript function (editing the values) but then we need to tell Bubble to do something with the result. This element helps us do that.</figcaption></figure><p><strong>Step 2: </strong>Create an HTML element to tell JS what our new function “bubble_fn_b” is supposed to do, and to do it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*8Ty96w0olDCnkiQdfg9wRQ.png" /><figcaption>Still blows my mind that we don’t have to close the script tag.</figcaption></figure><p>The above script is telling bubble to take the content of localStorage (which is currently a JavaScript object) and turn it into a JSON string, simple enough!</p><p><strong>Step 3: </strong>Create a Repeating Group, set the type of content to text, and set the data source to be your JavaScriptBubble (the one you created in Step 1) value: split by commas. As you can see below, I also have a few modifications to make it prettier:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*hp34rM2wXOUtdR5nD-oUxA.png" /></figure><p>Specifically, I used the ‘find &amp; replace’ to remove {}\” characters, and replaced the colon ‘:’ with a colon that had a space before and after to make it prettier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*TvwUENN0PX5p1agzLbkQIg.png" /></figure><p><strong>Step 4:</strong> Drop a text element in the RG, and set the value to be “Current cell’s text”</p><p>TADA!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*yhqOi5c2Nh_P7jqxWOoOGw.png" /><figcaption>I am sad that the order is not correct. I wonder why…..</figcaption></figure><h4>Cap 3: Displaying content based on the data</h4><p>Alright, the best part, is how do we take the data from a specific key-value pair, and use it dynamically. Step 1 and Step 2 are almost identical to the above capability, you will just need to create new elements.</p><p><strong>Step 1:</strong> Create a new JavaScript to Bubble element, just like you did for Cap 2, just name it something different this time. Mine is named “bubble_fn_a”.</p><p><strong>Step 2</strong>: Drop another HTML element, this time, use the following script:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*AOJQLLQ6Z48n0uiyocSo3Q.png" /></figure><p>&lt;script&gt;<br>setTimeout(function() {<br>bubble_fn_a(localStorage.getItem(“Color”));<br>},1000);</p><p>We are:</p><ul><li>Telling JavaScript to go to the user’s localStorage</li><li>Access the key-value pair with the key “Color”</li><li>Assign that keys value to “bubble_fn_a”</li></ul><p><strong>Step 3</strong>: Drop a Shape element (really any element that you can edit its background style) and assign its color to be “JavascriptBubble A’s value”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*5qNxvHW1ugzysu5BRZfN6Q.png" /><figcaption>TADAAAA!</figcaption></figure><p>That’s it! The shape will take on the color of whatever hex code is inputed for the key “Color”.</p><p>If you are too lazy to scroll up, you can play around with my example below:<br><a href="https://codebridged.com/example/localstorage">https://codebridged.com/example/localstorage</a></p><h3>Conclusion</h3><p>The localStorage is a powerful, lightweight SQL-style database that you can store and access data. You are capped at 5MB, so don&#39;t go crazy!</p><p>There are a few other commands you can use in localStorage, such as .removeItem() and .clear().</p><p>Finally, this isn’t meant to store any sensitive data or data you would want to access server-side (on the backend).</p><p>Thanks, and I hope you got something out of it! — Bek @ codebridged.com</p><h3>One more thing!</h3><p>I built a Figma to bubble converter, check it out at <a href="https://deezign.io/">deezign.io</a>!</p><p>I got tired of manually converting Figma designs, and the bubble one is no good, so I decided to build my own. It converts auto layout designs to flex in bubble, capturing all of the standard properties such as padding, gap, margin, etc. Check it out and let me know what you think!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12afc87c6ec9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>