Using Electron and communicating with remote server of Meteor app

I’m trying to build clients for the desktop client and the web as well. I want to use Electron to write my app once and then be able to deploy to the desktop and web.

The web server would host all of the data and the clients on desktop would only see what they are permitted to see (so not all the data is sent to them). I understand how this would work for the web version. But I’m not sure how this works for Electron. It looks like when I use arboleya/electrify it just uses the local database at localhost:3000 if I use the console command electrify It looks like it uses its own db instance when I do electrify package.

But if I wanted to communicate with how would that work? The app right now is basically an offline app. Basically I want the desktop version to be client side only and use the db at rather than its own local one.

Can someone provide some advice?

So, I’m looking for the same functionality, and this response

"nlammertynMay 12
Check my response on this thread: Windows/Desktop Application using Meteor - #24 by nlammertyn

Been using electrify for a few months now, I have nothing but good things to say about it. I did fork it for small adjustments and more control over electron versions.

The app falls in your 2.1 category, I do db syncing with a remote db through a remote server that diffs the local and remote db’s (by using md5 hashes of full collections and single documents, if they’re not equal the last updated version gets used, but I could extend this with versioning and ‘smart’ updates). Perhaps I’ll extend and publish the syncing code one day but really don’t have that kind of time right now. The app works perfectly both off- and online."

on this thread

Seems like a step in the right direction. I would love for someone to build this into an electron / meteor framework…wish I was good enough to do it myself.

Hope it helps,

Go for it. Become good by doing what you haven’t done before. You can even.

Any progress here? I’m using vanilla Electron-Boilerplate customized to point to a local Meteor server (e.g. meteor my-app) right now, and that works just fine, but I can’t seem to access the electron module from the client app using require('electron'). This connection and require works from a plain React app on a python server, but when using Meteor’s server, it throws a “Uncaught Error: Cannot find module ‘electron’” error. I don’t know enough about what Meteor’s doing under-the-hood to be able to really debug any further…

If you deactivated nodeIntegration you have to manually export what you need so Meteor has access to it.

For example, we are using a notification package on electron, and we export it so Meteor has access to it (window.electronNotifiation).

1 Like

So this is more or less all I’ve got going on here; on the client, I just have a script tag in the index.html file with
let ipc = window.require('electron').ipcRenderer;
I just set the nodeIntegration: true part explicitly, but still seeing the same error. How does manually exporting work? Are you just running some JS on the client from the background process?

1 Like

UPDATE: The problem was my script tag was in the body; moving it into the head solved everything. My bad!

1 Like

I see you got it figure it out. For future reference: we have a preload script, which loads everything we need before the app (Meteor) actually starts/load.

webPreferences: {
nodeIntegration: false,
preload: ${__dirname}/preload.js,
textAreasAreResizable: false,

1 Like

Great suggestion! Thanks!

This is somewhat tangential, but have you been able to get oauth working in these Electron-wrapped meteor apps? In particular, using { loginStyle: 'popup' } with the Meteor.loginWith[service] functions doesn’t seem to work unless I set the sandbox: true flag in webPreferences (which of course comes with its own side-effects).

Interesting. I didn’t tried with the default oauth of Meteor.loginWith but I did tried with a general oauth (1.0a), and works as expected. If you use, it opens a new window, redirects and closes it. Just as it should.

PS: I didn’t use sandbox.