How do you pull info from localStorage and display it in your electron app?


#1

Hello!

I’m working on a simple bookmark application and I want to implement localStorage so that the links will persist when reopening the application.

My application has an index.html file with the following template in it:

<template id="link-template">
      <article class="link">
        <h3 class="link--title"></h3>
        <p><a href="#" class="link--url"></a></p>
      </article>
    </template>

When I console.log(localStorage) inside my render.js file I get the following output in my Electron Inspector console:
Storage {Atom Discussion: "https://discuss.atom.io/", Google: "https://google.com/", length: 2}
so localstorage is working correctly.

My issue is that I’m not sure how to manipulate with the template so that when the app starts, data from the localStorage will get rendered using the template in my index.html.

Any help is more than appreciated, thank you so so much!


#2

Is there anything that I can add to make the question more clear?


#3

I recommend using Dexie and storing your data in IndexedDB.


#4

The example from the spec makes it look like you would manipulate the template the same way you typically manipulate the DOM; el.textContent, el.appendChild etc.

I’m not sure this question is Electron specific enough to make sense in this forum.