Qvault’s Offline Mode in Electron


The Qvault password manager is a deprecated project, this article remains alive for historical informational purposes only. Our new product can be found at Qvault.

We recently added “Offline Mode” to Qvault as a new feature. This was in preparation to also add Bitcoin and cryptocurrency key generation. There is now a toggle switch at the top of the app that, when switched off, ensures that the app will make no network requests.

offline mode addition

You have always been able to use Qvault offline, that is, assuming the user chose not to sign up for Qvault’s cloud backup option. Now, even if a user is storing their encrypted vault files on Qvault servers, the user can choose to go offline and work locally temporarily.

How Does it Work?

Electron has an API that allows developers to intercept and modify web requests. By intercepting all webRequests before they are made using the onBeforeRequest hook, we can check them see if we want to allow each request or not. For example:

// callback({cancel: true}) stops the request before it is sent.
// callback({cancel: false}) sends the webRequest

    // Intercept all webRequests
    urls: [ '<all_urls>' ]
  }, (details, callback) => {
    // allow all filesystem calls
    if (details.url.substring(0, details.url.indexOf(':')) == 'file'){
      callback({cancel: false});
    // don't allow any network calls if in offlineMode
    if (!onlineMode){
      callback({cancel: true});
    // allow al other network calls
    callback({cancel: false});

Hopefully, this helps anyone else looking to control webRequests in Electron, and helps our users understand ‘offline mode’ in Qvault! Thanks for reading.

Thanks for reading, now take a course!

Interested in a high-paying job in tech? Land interviews and pass them with flying colors after taking my hands-on coding courses.


Follow and hit me up on Twitter @q_vault if you have any questions or comments. If I’ve made a mistake in the article be sure to let me know so I can get it corrected!

Subscribe to my newsletter for more coding articles delivered straight to your inbox.