Skip to content
A library to connect NodeJs application with executables from other languages
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
spec Initial commit Feb 26, 2019
LICENSE Fixed typo in readme Feb 26, 2019
index.js Initial commit Feb 26, 2019

Electron CGI

Electron CGI is a NodeJs library (npm package: electron-cgi) that makes interacting with executables from other languages easy.

Currently there's support for .Net through the ElectronCgi.DotNet Nuget package.

Here's an example of how you can interact with a .Net application:

In NodeJs/Electron:

const { ConnectionBuilder } = require('electron-cgi');

const connection = new ConnectionBuilder()
        .connectTo('dotnet', 'run', '--project', 'DotNetConsoleProjectWithElectronCgiDotNetNugetPackage')

connection.onDisconnect = () => {
    console.log('Lost connection to the .Net process');

connection.send('greeting', 'John', theGreeting => {
    console.log(theGreeting); // will print "Hello John!"


And in the .Net Console Application:

using ElectronCgi.DotNet;

static void Main(string[] args)
    var connection = new ConnectionBuilder()

    // expects a request named "greeting" with a string argument and returns a string
    connection.On<string, string>("greeting", name =>
        return $"Hello {name}!";

    // wait for incoming requests

How does it work?

Electron CGI establishes a "connection" with an external process. That external process must be configured to accept that connection. In the example above that's what the Listen method does.

In Node we can "send" requests (for example "greeting" with "John" as a parameter) and receive a response from the other process.

The way this communication channel is established is by using the connected process' stdin and stdout streams. This approach does not rely on staring up a web server and because of that introduces very little overhead in terms of the requests' round-trip time.

You can’t perform that action at this time.