Core Concepts

Overview

The purpose of the Main app is to handle complex and important operations, but its setup is extremely simple and easy.

Initialization

Install the @glue42/web-platform in your project:

npm install @glue42/web-platform

Import the package in your Main app and initialize the Glue42 Web Platform library using the GlueWebPlatform() factory function:

import GlueWebPlatform from "@glue42/web-platform";

// Use the `glue` property of the object returned
// by the factory function to access the Glue42 APIs.
const { glue } = await GlueWebPlatform();

The factory function will initialize and configure everything needed for a fully functioning Glue42 Core project.

Configuration

Optionally, specify configuration settings for other Glue42 libraries or Plugins initialized by the GlueWebPlatform() function:

import GlueWebPlatform from "@glue42/web-platform";
import GlueWorkspaces from "@glue42/workspaces-api";

const config = {
    glue: {
        // Enabling the Workspaces API.
        libraries: [GlueWorkspaces]
    },
    workspaces: {
        // Specifying the location of the Workspaces App.
        src: "https://my-workspaces-app.com"
    }
};

const { glue } = await GlueWebPlatform(config);

Use this configuration object to set various important aspects of your Glue42 Core project.

Property Description
windows Override various timeouts for the Window Management operations.
applications Set a source for app definitions by passing an array of app definition objects to the local property of this object.
layouts Set a source for Layout definitions by passing an array of Layout definition objects to the local property of this object. Set the mode of the Layouts library ("idb" or "session") with the mode property. See the Layouts section.
channels Configure the Glue42 Channels that will be available in your project.
workspaces Set a location of your Workspaces App and other options for Workspaces.
plugins Provide your custom Glue42-specific logic, which will be included in the boot sequence of the Main app. See the Plugins section.
connection Defines settings for connecting to a local Glue42 Enterprise instance. See the Connecting to Glue42 Enterprise section.
glue A Config object for the Glue42 Web library that will be used when registering the Main app as a Glue42 client in Glue42 Enterprise.
gluefactory The Glue42 Web Platform library will always initialize the latest version of Glue42 Web internally, but you can override this by passing your own Glue42 factory function. This is especially helpful if you want your Main app to run with a specific @glue42/web package version and not the latest.
gateway Override the logging levels and handlers of the Glue42 Gateway for advanced control and debugging.
serviceWorker Provide the Service Worker registered by your Main app. A Service Worker is necessary only if you want to use Notifications with actions.
clientOnly Set to true to initialize your Main app as a Web Client app, skipping all Web 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 Web Client. In such cases it's possible to acquire Web Platform configuration or logic at runtime if your app should be a Main app.
environment An object with custom data (excluding functions) that will be accessible through the glue42core object attached to the global window object of the Main app and all Web Client apps connected to it.

For detailed explanations and examples of each setting, see the corresponding entries in the Capabilities and Developers sections.