Browser Platform

Overview

The purpose of the Main app is to handle complex and important operations, but its setup is extremely simple and easy. The following sections describe how to create a Main app for your io.Connect Browser project and install and initialize properly the respective libraries depending on the web framework you are using - JavaScript ( @interopio/browser-platform), React (@interopio/react-hooks), or Angular (@interopio/ng). All libraries are free to install from the public NPM registry, but require a valid license to operate.

ℹ️ For information on purchasing the io.Connect Browser platform or requesting a trial license, contact us.

Initialization

JavaScript

Install the @interopio/browser-platform library in your project:

npm install @interopio/browser-platform

Import the package in your Main app and initialize the @interopio/browser-platform library using the IOBrowserPlatform() factory function. It's required to provide a valid license key in the configuration object for the library:

import IOBrowserPlatform from "@interopio/browser-platform";

// Configuration for initializing the library.
// The only required property is `licenseKey`.
const config = {
    licenseKey: "my-license-key"
};

// Use the `io` property of the object returned by
// the factory function to access the io.Connect APIs.
const { io } = await IOBrowserPlatform(config);

The factory function will initialize and configure everything needed for a fully functioning io.Connect Browser project.

React

ℹ️ For more details on using the @interopio/react-hooks library, see the Browser Client > React section.

Install the @interopio/react-hooks library in your project:

npm install @interopio/react-hooks

Initialize the @interopio/react-hooks library in one of the following ways. It's required to provide a valid license key in the configuration object for the library:

  • using the <IOConnectProvider /> component:
import { createRoot } from "react-dom/client";
import IOBrowserPlatform from "@interopio/browser-platform";
import { IOConnectProvider } from "@interopio/react-hooks";

// Settings for the internal initialization of the `@interopio/browser-platform` library.
const settings = {
    browserPlatform: {
        factory: IOBrowserPlatform,
        config: {
            licenseKey: "my-license-key"
        }
    }
};

const domElement = document.getElementById("root");
const root = createRoot(domElement);

root.render(
    // Wrap your root component in the `<IOConnectProvider />` component in order
    // to be able to access the io.Connect APIs from all child components.
    <IOConnectProvider fallback={<h2>Loading...</h2>} settings={settings}>
        <App />
    </IOConnectProvider>
);
  • using the useIOConnectInit() hook:
import IOBrowserPlatform from "@interopio/browser-platform";
import { useIOConnectInit } from "@interopio/react-hooks";

const App = () => {
    const settings = {
        browserPlatform: {
            factory: IOBrowserPlatform,
            config: {
                licenseKey: "my-license-key"
            }
        }
    };

    const io = useIOConnectInit(settings);

    return io ? <Main io={io} /> : <Loader />;
};

export default App;

Angular

ℹ️ For more details on using the @interopio/ng library, see the Browser Client > Angular section.

The following table describes the Angular versions supported by the different major versions of the @interopio/ng library:

Library Version Supported Angular Versions
@interopio/ng 6.0 Supports Angular versions 19 and 20. Supports both standalone components and modules. Provides the provideIoConnect() function for configuring and initializing the @interopio/ng library in Angular apps that use standalone components.
@interopio/ng 5.0 Supports all Angular versions up to and including 20. Supports both standalone components and modules.

If you have created your app with the Angular CLI, then you don't need to take any additional steps. Otherwise, make sure to install the peer dependencies of @interopio/ng described in the package.json file of the library.

Install the @interopio/ng library in your project:

npm install @interopio/ng

Initialize the @interopio/ng library in one of the following ways depending on whether you are using standalone components or modules. It's required to provide a valid license key in the configuration object for the library.

Standalone Components

In app.config.ts of the Main app:

import { ApplicationConfig } from "@angular/core";
import { provideIoConnect } from "@interopio/ng";
import IOBrowserPlatform, { IOConnectBrowserPlatform } from "@interopio/browser-platform";

// Main app configuration.
const config: IOConnectBrowserPlatform.Config = {
    licenseKey: "my-license-key"
};

export const appConfig: ApplicationConfig = {
    providers: [
        // Configuring and initializing the Main app.
        provideIoConnect({
            browserPlatform: {
                factory: IOBrowserPlatform,
                config
            }
        })
    ]
};

In main.ts of the Main app:

import { bootstrapApplication } from "@angular/platform-browser";
import { appConfig } from "./app/app.config";
import { App } from "./app/app";

bootstrapApplication(App, appConfig);

Modules

The following example demonstrates initializing the @interopio/ng library in a Main app that use Angular versions 15 and later.

In app.config.ts of the Main app:

import { ApplicationConfig, importProvidersFrom } from "@angular/core";
import { IOConnectNg } from "@interopio/ng";
import IOBrowserPlatform, { IOConnectBrowserPlatform } from "@interopio/browser-platform";

const config: IOConnectBrowserPlatform.Config = {
    licenseKey: "my-license-key"
};

export const appConfig: ApplicationConfig = {
    providers: [
        importProvidersFrom(
            IOConnectNg.forRoot({
                browser: {
                    factory: IOBrowserPlatform,
                    config
                }
            })
        )
    ]
};

The following example demonstrates initializing the @interopio/ng library in a Main app that use Angular versions 14 and older.

In app.module.ts of the Main app:

import { NgModule } from "@angular/core";
import { AppComponent } from "./app.component";
import { IOConnectNg } from "@interopio/ng";
import IOBrowserPlatform, { IOConnectBrowserPlatform } from "@interopio/browser-platform";

const config: IOConnectBrowserPlatform.Config = {
    licenseKey: "my-license-key"
};

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        IOConnectNg.forRoot({
            browserPlatform: {
                factory: IOBrowserPlatform,
                config
            }
        })
    ],
    providers: [],
    bootstrap: [AppComponent]
});

export class AppModule { };

Configuration

It's required to provide a valid license key in order to be able to initialize the Main app of your io.Connect Browser project.

You can also specify other optional settings for the io.Connect environment, APIs, libraries, and Plugins by using the configuration object for initializing the @interopio/browser-platform library:

import IOBrowserPlatform from "@interopio/browser-platform";
import IOWorkspaces from "@interopio/workspaces-api";

const config = {
    // Providing a valid license key.
    licenseKey: "my-license-key",
    browser: {
        // Enabling the Workspaces API.
        libraries: [IOWorkspaces]
    },
    workspaces: {
        // Specifying the location of the Workspaces App.
        src: "https://my-workspaces-app.com"
    },
    // Configuration for Global Layouts.
    layouts: {
        mode: "session"
    },
    // Configuration for connecting to io.Manager.
    manager: {
        url: "https://my-io-manager.com:4242/api",
        auth: {
            basic: {
                username: "username",
                password: "password"
            }
        },
        fetchIntervalMS: 10000,
        tokenRefreshIntervalMS: 15000,
        critical: true
    }
};

const { io } = await IOBrowserPlatform(config);

The configuration object for the @interopio/browser-platform library has the following properties:

Property Type Description
applications object Set a local or remote source for app definitions.
browser object Config object for the internal initialization of the @interopio/browser library. This configuration will be used also if the Main app is registered as an io.Connect client in an io.Connect Desktop project.
browserFactory function The @interopio/browser-platform library will always initialize the latest version of the @interopio/browser library internally, but you can override this by passing your own io.Connect factory function. This is especially helpful if you want your Main app to run with a specific @interopio/browser library version and not the latest.
channels object Configure the Channels that will be available in your project.
clientOnly boolean Set to true to initialize your Main app as a Browser Client app, skipping all Browser Platform related logic. Useful in certain cases during initialization when it isn't explicitly clear whether your app should be a Main app or a Browser Client. In such cases it's possible to acquire Browser Platform configuration or logic dynamically if your app is to be a Main app.
connection object Defines various security connection settings as well as settings for connecting to a local io.Connect Desktop instance.
environment object Object with custom data (excluding functions) that will be accessible via the iobrowser object injected in the global window object of the Main app and all Browser Client apps connected to it.
gateway object Configuration for the io.Connect Gateway. Includes settings for connecting to io.Bridge. For more details, see the Capabilities > io.Bridge section.
intentResolver object Configuration for the io.Connect Intent Resolver. Available since io.Connect Browser 4.0.
layouts object Configuration for Global Layouts.
licenseKey string Required. Valid license key for enabling the io.Connect Browser platform.
manager object Configuration for connecting to io.Manager. For more details, see the Capabilities > io.Manager section.
modals object Configuration for the io.Connect modal windows. Available since io.Connect Browser 4.0.
notifications object Configuration for the io.Connect Browser notifications.
otel object Configuration for io.Insights. For more details, see the Capabilities > io.Insights section. Available since io.Connect Browser 3.4.
plugins object Provide your custom logic which will be included in the boot sequence of the Main app. For more details, see the Plugins section.
serviceWorker object Provide the Service Worker registered by your Main app. A Service Worker is necessary only if you want to use Notifications with actions.
themes object Configuration for the io.Connect Themes.
user object Object describing the current platform user. It's highly recommended to set at least the id property of the user object as the user details are consumed internally by the platform for caching and visualization purposes.
widget object Configuration for the io.Connect widget. Available since io.Connect Browser 3.5.
windows object Configuration for the Window Management API.
workspaces object Configuration for the Workspaces App and Workspaces.

Remote Configuration

It's possible to provide configuration for your Main app from a remote source (e.g., by retrieving a custom configuration file from io.Manager or your own REST store).

To achieve this, you must implement your own logic for fetching the remote configuration file and passing it to your Main app. It's recommended to cache the configuration file so that it will be available and your Main app can be initialized even in cases of connection interruptions.

The following example demonstrates an opinionated approach for fetching a remote configuration file and initializing the Main app. The example uses Boolean flags stored in the remote configuration file that indicate which additional io.Connect libraries to initialize in the Main app. If this approach doesn't work for you, you should implement a different solution based on your specific use case:

import IOBrowserPlatform, { IOConnectBrowserPlatform } from "@interopio/browser-platform";
import IOWorkspaces from "@interopio/workspaces-ui-react";

// Example REST store response structure.
interface ConfigPayload {
    // Standard configuration object for initializing the Main app. It's required to provide a valid license key.
    config: IOConnectBrowserPlatform.Config;
    // Optional object with Boolean flags indicating which additional io.Connect libraries to initialize.
    apis?: {
        workspaces?: boolean;
        modals?: boolean;
        search?: boolean;
    };
}

const start = async () => {
    // Fetching the remote configuration file for the Main app.
    const response = await fetch("https://my-rest-store");

    const configPayload: ConfigPayload = await response.json();

    // Extracting the standard configuration object for the Main app and the object with Boolean flags
    // indicating which additional io.Connect libraries to initialize.
    const { config, apis } = configPayload;

    // The `libraries` array will hold the factory functions for initializing the additional io.Connect libraries.
    const libraries = [];

    // The factory functions for initializing the additional io.Connect libraries can't be serialized as JSON.
    // To determine which libraries to initialize, use the Boolean flags stored in the `api` object of the
    // remote configuration file and push the respective factory function in the `libraries` array.
    if (apis?.workspaces) {
        libraries.push(IOWorkspaces);
    }

    // Ensuring that the `browser` property of the configuration object for the Main app exists
    // and that all its current settings will be preserved while also adding the `libraries` array.
    config.browser = { ...config.browser, libraries };

    const { io } = await IOBrowserPlatform(config);
};

start().catch(console.error);

User Details

While the io.Connect Browser platform isn't meant to handle user authentication and while providing user details when initializing the platform is entirely optional, it's still highly recommended to do so.

User details can be used internally for separating the cache (app definitions, app preferences, Layouts) for different platform users on the same machine. For instance, providing any form of user ID will allow the platform to save default Global Layouts per user. If user details aren't provided (and the platform isn't connected to io.Manager, which handles user cache separation automatically), the default Global Layout will be saved as public for all users.

The details provided in the user object are also used in the Profile panel of the Home App if you are building a platform by using the @interopio/home-ui-react library.

The user object has the following properties:

Property Type Description
email string User email.
firstName string User first name.
id string Required. Unique ID for the user.
lastName string User last name.
meta any Any meta data associated with the user.
role string Role of the user.
type string Type of the user.
username string Username for the user.

io.Connect JavaScript Capabilities

Once the @interopio/browser-platform library has been initialized, your Main app has access to all io.Connect functionalities. For more detailed information on the different io.Connect capabilities and APIs, see the following sections: