2

I am working on an Electron app that needs to be able to retrieve localStorage on the default OS browser from my site. How can I achieve that? Are there any API's/Modules? I was thinking something like this:

var electron = require("electron");
var storage = electron.OSBrowser.storage;

But I am pretty sure that does not exist. Thanks. (FYI I am in the Renderer not the main process)

  • Possible duplicate of [Where an electron application's sessionStorage and localStorage stored?](https://stackoverflow.com/questions/43912928/where-an-electron-applications-sessionstorage-and-localstorage-stored) – ic3b3rg Jun 02 '18 at 07:24
  • 1
    Nope, completely different. – QuestionExterminator Jun 02 '18 at 20:20
  • I'm also interested in this and after some investigation I'm convinced this is a question of (1) locating where individual browsers store their localStorage data (i.e. where on disk), and (2) extracting that raw data from there (e.g. using `fs` to read it). This might prove really difficult, as the user may not use their default browser, so you need to scan and detect every considerably common browser to implement general support. Storage location may also change over time. For Chrome, see: https://stackoverflow.com/questions/15801798/where-is-google-chrome-local-storage-saved – John Weisz Dec 27 '18 at 11:34

1 Answers1

1

Your question is a bit confusing because we don't know what "default browser" and "my site" are in your question's context. Since Electron ships with Chromium, the "default browser" is known: its Chromium. And since Chromium is HTML5 compliant, you can just use normal LocalStorage methods in your Renderer process.

When you say "my site" it makes it sound like you are expecting Electron to run from the web; it doesn't, its a local app on your PC/Mac.

If this answer doesn't help, we're going to need a lot more detail from you to narrow down your need.

Geek Stocks
  • 2,010
  • 3
  • 27
  • 43
  • Default browser as in the OS's default browser. Basically I am trying to get the localStorage of my site on the OS's default browser so I can use it in my Electron app. – QuestionExterminator Jun 02 '18 at 20:20
  • Since the browser on the OS can vary, that will be a challenge. Additionally, during install, the location of those files COULD change based on the user's input (if defaults are not accepted). This might be best handled with a config JSON document where the user can locate the files during setup. The link provided above by @ic3b3rg is quite helpful in your case. – Geek Stocks Jun 05 '18 at 08:24