How to...

Referencing

The io.Connect JavaScript library is available as a single JavaScript file, which you can include in your apps. If you are using an io.Connect installer, you can find the JavaScript files in %LocalAppData%/interop.io/io.Connect Desktop/SDK/ioDesktopJS/js. When deploying your app in production, it is recommended to always reference a specific minified version:

import IODesktop from "../scripts/desktop.umd.min.js";

The io.Connect JavaScript library is also available as an NPM package, which you can include as a dependency in your project and import in your code. The currently available packages are @interopio/core and @interopio/desktop. The Core package is a subset of the Desktop package and offers basic functionalities for sharing data between apps (Interop, Shared Contexts, Pub/Sub, Metrics), while the Desktop package offers additional options for sharing data between apps (Channels), as well as advanced window management functionalities (App Management, Layouts, Window Management).

To include any of the packages as a dependency in your project, navigate to the root directory of your project and run:

npm install @interopio/desktop

To reference the io.Connect library:

const IODesktop = require("@interopio/desktop");

Initialization

If your Node.js app is started by io.Connect Desktop, it isn't required to pass authentication information in the optional configuration object passed to the factory function:

const IODesktop = require("@interopio/desktop");

// This will prevent the app from exiting when io.Connect is initialized.
// Remove in real apps.
setTimeout(()=>{
    console.log("Done.");
}, 10000);

const initializeIOConnect = async () => {
    // Optional configuration for intializing the library.
    const config = { activities: false };

    // Use the object returned by the factory function to access the io.Connect APIs.
    const io = await IODesktop(config);

    // Here io.Connect is initialized and you can access all io.Connect APIs.

    console.log(`io.Connect version: ${io.version}`);
};

initializeIOConnect().catch(console.error);

App Definition

To add your Node.js app to the io.Connect launcher, you must create a JSON file with app definition. Place this file in the %LocalAppData%/interop.io/io.Connect Desktop/UserData/<ENV>-<REG>/apps folder, where <ENV>-<REG> represents the environment and region of io.Connect Desktop (e.g., DEMO-INTEROP.IO).

The following is an example definition of a Node.js app:

{
    "name": "node-server",
    "type": "node",
    "service": true,
    "details": {
        "path": "%GDDIR%/PathToMyServer/index.js",
        "showConsole": true
    }
}

The "name", "type" and "path" properties are required and "type" must be set to "node". The "path" property points to a JavaScript file that io.Connect Desktop will execute in a Node.js environment.

For details on how to configure a remotely hosted Node.js app, see the Developers > Configuration > Application section.

For details on how to use different Node.js versions, see the Using Different Node.js Versions section.

io.Connect JavaScript Capabilities

Once the io.Connect JavaScript library has been initialized, your app has access to all io.Connect functionalities. For more detailed information on the different io.Connect capabilities and APIs, see:

Reference

For a complete list of the available JavaScript APIs, see the io.Connect JavaScript Reference Documentation.